incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r948087 [2/3] - in /incubator/aries/trunk/samples/goat: ./ goat-api/ goat-api/src/ goat-api/src/main/ goat-api/src/main/java/ goat-api/src/main/java/org/ goat-api/src/main/java/org/apache/ goat-api/src/main/java/org/apache/aries/ goat-api/s...
Date Tue, 25 May 2010 16:13:17 GMT
Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/grid_sort_down.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/grid_sort_up.gif
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/grid_sort_up.gif?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/grid_sort_up.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header_shadow.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header_shadow.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/header_shadow.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/resolved.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/resolved.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/resolved.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/row_back.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/row_back.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/row_back.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/running.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/running.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/running.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabEnabled_rotated.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabEnabled_rotated.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabEnabled_rotated.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabHover_rotated.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabHover_rotated.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/tabHover_rotated.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/td_button_down.png
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/td_button_down.png?rev=948087&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/images/td_button_down.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js Tue May 25 16:13:13 2010
@@ -0,0 +1,261 @@
+/**
+ * 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.
+ */
+dojo.provide("goat.Component");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.fx");
+dojo.require("dojox.gfx.Moveable");
+
+dojo.require("goat.elements.ElementBase");
+dojo.require("goat.elements.ElementRegistry");
+dojo.require("goat.elements.ComponentContainer");
+dojo.require("goat.elements.TextComponentProperty");
+dojo.require("goat.RelationshipManager");
+dojo.require("goat.ElementLayoutManager");
+
+
+
+//Component,
+// looks after a component shape on the surface.
+//
+dojo.declare("goat.Component", [], {
+
+	//fixed properties.
+	
+                         /*String*/       id: null,     //must be unique within enclosing component, if any, or globally if none.
+	           /*goat.Component[]*/ children: null,
+	/*goat.elements.ElementBase[]*/ elements: null, //gui display elements within this component, all must extend 'goat.elements.ElementBase'
+	
+	//manager objects.. 
+	/*goat.RelationshipManager*/   relationshipManager: null, //manager for handling all relationships to/from this component.
+	/*goat.ElementLayoutManager*/ elementLayoutManager: null, //manager for arranging elements within a component.
+	/*goat.elements.ElementRegistry*/  elementRegistry: null, //manager for returning appropriate renderers for component elements
+
+	//state.
+	/*boolean*/   hidden: false,    //is component visible on the surface.
+	/*boolean*/ selected: false,    //is mouse currently within our boundary ?
+	/*boolean*/ refreshing: false,  //is a refresh in progress ?
+	
+	//gfx objects
+	/*dojox.gfx.Group*/     group: null,
+	/*dojox.gfx.Surface*/ surface: null,
+	/*dojox.gfx.Rect*/    outline: null,
+		
+	//dimensions/coords - onsurface positioning.
+	/*int*/  x: 0,
+	/*int*/  y: 0,
+	/*int*/  width: null,
+	/*int*/  height: null,
+	
+	/*int*/  minWidth: 150, 
+	/*int*/  minHeight: 80,
+		
+	
+	
+constructor: function(/*dojox.gfx.Surface*/surface, 
+		              /*String*/id, 
+		              /*String[]*/props, 
+		              /*goat.Component[]*/ children) {
+	
+	this.surface=surface;
+	this.x=0;
+	this.y=0;
+	this.height=115;
+	this.width=this.minWidth;
+		
+	//console.log("Adding Box");
+	this.initGfx();
+	
+	this.id=id;	
+	this.elements=new Array();
+	
+	this.children=children;	
+	if(this.children!=null){
+		  var type = "component.container";
+		  var element = this.elementRegistry.getProperty(this.group, type, children);
+		  this.elements[type]=element;
+	}	
+		
+	this.elementRegistry = new goat.elements.ElementRegistry(this,props);
+	this.elementRegistry = this.elementRegistry.getRegistry();
+	
+	this.updateProperties(props);
+	
+	//console.log("Creating RM");
+	this.relationshipManager = new goat.RelationshipManager(this);
+	//console.log("Creating ELM");
+	this.elementLayoutManager = new goat.ElementLayoutManager(this);
+		
+	//console.log("Invoking refresh");
+	this.refresh();
+
+	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("goat.component.create",[this]);
+    
+    dojo.subscribe("goat.component.refresh", this, this.onRefresh);
+},
+updateProperties: function(props){
+	//console.log("Processing properties");
+	//console.log(props);
+	
+	this.componentProperties=new Array();
+	for (var key in props){		  
+		  var value = props[key];
+		  //console.log("The fieldname or key is: "+key+" and the value at that field is: "+value);
+		  var type = "component.property."+key;
+		  if(this.elements[type]==null){
+		    var element = this.elementRegistry.getProperty(this, type, value);
+		    this.elements[type]=element;
+		  }else{
+			this.elements[type].update(value);
+		  }
+	}	
+	//TODO: what about elements in this.elements that were not present in props, 
+	//      should they be removed from the this.elements array.. currently elements dont
+	//      support a 'remove' method. 
+	//      for now, as components dont need removing, wont worry about this.
+	
+	//console.log("Properties processed.");	
+},
+removeSelf: function() {
+	this.surface.remove(this.group);
+	dojo.publish("goat.component.delete", [this]);
+},
+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" } ]});
+       
+},
+refresh: function(){
+	//console.log(">Component.refresh");
+	this.elementLayoutManager.doLayout();
+	
+	//console.log("Sizing box");
+	//not compatible with component shape property!
+	this.outline.setShape({x: 0, y: 0, width: this.width, height: this.height, r: 5});
+	
+	//console.log("Movng to front");
+	//make sure we can be seen.
+	this.group.moveToFront();
+	//console.log("<Component.refresh");
+},
+update: function(id, props, children) {	
+	
+	//console.log("Updating "+id+", processing properties array.. ");
+	
+	//rebuilds the prop array internally
+	this.updateProperties(props);
+	
+	//console.log("Updating "+id+", rebuilding onscreen with new props ");
+	//rebuild the onscreen object with the layout mgr 
+	this.refresh();
+	
+	//TODO: update children.
+		
+	//tells everyone who cares that we just did that.
+	dojo.publish("goat.component.update."+this.id,[this]);
+},
+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("goat.component.hidden",[this.id,hideMe]);
+	dojo.publish("goat.component.hidden."+this.id, [this]);
+},
+onMoved: function(mover, shift) { 
+	//this may stop working once this.group isnt directly within the surface
+	//(ie once child components are renderable)
+    this.x=this.group.matrix.dx;
+    this.y=this.group.matrix.dy;
+    
+	this.updateAfterMove();
+},
+updateAfterMove: function(){
+	dojo.publish("goat.component.move",[this.id,this.x,this.y]);
+	dojo.publish("goat.component.move."+this.id, [this]);
+},
+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();
+},
+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();
+	dojo.publish("goat.component.onclick."+this.id, [this]);
+},
+onMouseEnter: function() {
+	this.outline.setStroke({width: 3, color: '#FF3030'});
+	this.selected=true;
+	dojo.publish("goat.component.onenter."+this.id, [this]);
+},
+onMouseLeave: function() {
+	this.selected=false;
+	this.glow();
+	dojo.publish("goat.component.onexit."+this.id, [this]);
+},
+onRefresh: function() {
+	if(!this.refreshing){
+		this.refreshing=true;
+		this.refresh();
+		this.refreshing=false;
+	}
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ComponentStatusGrid.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ComponentStatusGrid.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ComponentStatusGrid.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ComponentStatusGrid.js Tue May 25 16:13:13 2010
@@ -0,0 +1,241 @@
+/**
+ * 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.
+ */
+
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.ComponentStatusGrid");
+dojo.require("dojox.grid.DataGrid");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//TODO:
+
+//this has been partly converted to components.. 
+//it knows too much about component properties at present.
+
+dojo.declare("goat.ComponentStatusGrid", [], {
+	hidecoords: true,
+	grid:null,
+	jsonStore:null,
+	dataItems:{ identifier : 'id',	label : 'name',	items : [] },
+	lastMouseOverIndex:-1,
+constructor : function(where) {
+	var layout = [ 
+	{
+		name : "Unique ID",
+		field : "id",
+		width : "auto",
+		hidden : true
+	}, {
+		name : "ID",
+		field : "bundleid",
+		width : "20px"
+	}, {
+		name : "SymbolicName",
+		field : "name",
+		width : "auto" //"155px"
+	}, {
+		name : "State",
+		field : "state",
+		width : "12px",
+		formatter : this.makeStateImage
+	}, {
+		name : "x",
+		field : "x",
+		width : "15px",
+	    hidden : this.hidecoords
+	}, {
+		name : "y",
+		field : "y",
+		width : "15px",
+		hidden : this.hidecoords
+	}, {
+		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(component){
+				console.log(component);
+				console.log(component.id);
+				components[component.id].onClick();
+			});
+		} 
+	});
+	dojo.connect(grid, "onRowMouseOver", function(evt){
+		if(_this.lastMouseOverIndex!=evt.rowIndex){
+			components[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("goat.component.create", this, this.onComponentCreate);
+	dojo.subscribe("goat.component.delete", this, this.onComponentDelete);
+	dojo.subscribe("goat.component.update", this, this.onComponentUpdate);
+	dojo.subscribe("goat.component.hidden", this, this.onComponentHidden);
+	
+	if(!this.hidecoords){
+	  dojo.subscribe("goat.component.move", this, this.onComponentMove);
+	}
+},
+onComponentCreate: function(/*goat.Component*/ component){
+	//console.log(">onComponentCreate");
+	//console.log(component);
+	//add the component to the backing store
+	if (this.jsonStore != null) {
+			
+		//read through the property elements to their values.. 
+		var id = component.elements["component.property.BundleID"].value;
+		var name = component.elements["component.property.SymbolicName"].value;
+		var state = component.elements["component.property.State"].value;
+		var version = component.elements["component.property.Version"].value;
+		
+		this.jsonStore.newItem({id: component.id, bundleid: id, name: name, state: state, version: version, x: component.x, y: component.y});
+	}
+	this.jsonStore.save();
+	//console.log("<onComponentCreate");
+},
+onComponentDelete: function(component){
+	//console.log("onComponentDelete");
+	//console.log(component);
+	//console.log("invoking fetch for "+component.id);
+	var _this=this;
+	this.jsonStore.fetch({query: { id: component.id }, onComplete: function(item){
+		//console.log("Deleting "+item[0].id);
+		//console.log(item[0]);
+		_this.jsonStore.deleteItem(item[0]);
+	}});
+	this.jsonStore.save();
+	//console.log("<onComponentDelete");
+},
+onComponentUpdate: function(component){
+	//console.log(">onComponentUpdate");
+
+	var bid = component.elements["component.property.BundleID"].value;
+	var name = component.elements["component.property.SymbolicName"].value;
+	var state = component.elements["component.property.State"].value;
+	var version = component.elements["component.property.Version"].value;
+
+	var _this=this;
+	this.jsonStore.fetch({query: { id: id }, onComplete: function(item){
+		_this.jsonStore.setValue(item[0], "bundleid", bid);
+		_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("<onComponentUpdate");
+},
+onComponentHidden: function(id,hidden){
+	//console.log(">onComponentHidden");
+	var _this=this;
+	this.jsonStore.fetch({query: { id: id }, onComplete: function(item){
+		_this.jsonStore.setValue(item[0], "hidden", hidden);
+	}});
+	this.jsonStore.save();
+	//console.log("<onComponentHidden");
+},
+onComponentMove: function(id,x,y){
+	//optimisation, only process the move if we are displaying the coords...
+	if(!this.hidecoords){
+		//console.log("onComponentMove");
+		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 "+components[pk].id;
+	if(!components[pk].hidden){
+		checked="checked";
+		text="Hide "+components[pk].id;
+	}
+	var showBox = "<div dojoType=\"dijit.form.Button\">";
+	showBox = showBox + "<input type=\"checkbox\" ";
+	showBox = showBox + "title=\""+text+"\" ";
+	showBox = showBox + "onClick=\"hideComponent('"+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/goat/goat-web/src/main/resources/web/goat/Config.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Config.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Config.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Config.js Tue May 25 16:13:13 2010
@@ -0,0 +1,8 @@
+//this isnt a dojo class.. and is just a global object with named fields.. 
+//eventually this will be where the other objects come to find their settings.. probably..
+
+config = {
+   option : null,
+   layoutManager : null,
+   elementRegistry : null
+};

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ConfigManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ConfigManager.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ConfigManager.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ConfigManager.js Tue May 25 16:13:13 2010
@@ -0,0 +1,20 @@
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.ConfigManager");
+
+//not even started this yet.. the idea is to have a config panel for the global config, allowing 
+//all sorts of magic stuff to be done ;-) .. yeah.. right..
+
+dojo.declare("goat.ConfigManager", [], {
+	
+    dialog:null,
+
+	constructor : function() {
+		this.dialog = new dijit.Dialog({title:"Configuration", id:"configDialog"});
+
+		dojo.body().appendChild(this.dialog.domNode);
+		this.dialog.hide();
+}
+
+
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/DwrLoadingDialog.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/DwrLoadingDialog.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/DwrLoadingDialog.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/DwrLoadingDialog.js Tue May 25 16:13:13 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.DwrLoadingDialog");
+dojo.require("dijit.Dialog");
+
+//not sure this is working anymore..
+//it worked best when js was making requests TO the server.. 
+//but we've got it flipped so that the js makes a quick request, which causes the server to make calls back to us
+//might revisit this at some point to try to have the long requests all be client initiated, so we can display the dialog.
+
+dojo.declare("goat.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;
+	}	
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js Tue May 25 16:13:13 2010
@@ -0,0 +1,111 @@
+/**
+ * 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.
+ */
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.ElementLayoutManager");
+
+//Positions elements within a Component. 
+dojo.declare("goat.ElementLayoutManager", [], {
+
+	owningComponent: null,
+	layoutElements: null,
+
+constructor : function(owningComponent) {
+	//console.log("Building elementLayoutMananger");
+	console.log(owningComponent);
+	this.owningComponent = owningComponent;
+},
+doLayout: function(){	
+    console.log(">doLayout");
+    //console.log(this.owningComponent.elements);
+    
+	if(this.layoutElements!=null){
+		this.owningComponent.group.remove(this.layoutElements);
+		//console.log("removing old group");
+	}
+	//console.log("adding layout element group");
+	this.layoutElements = this.owningComponent.group.createGroup();
+	
+	var yOffset=0; //needed to compensate for how strings get rendered.
+
+	var yMargin=5;
+	var xMargin=5;
+	var rowPad=2;
+	
+	var currentYPos=yMargin + yOffset;
+	
+	var maxWidth = 0;
+    var sepYPos = new Array();
+	
+	//console.log("processing array.. ");
+	//walk through each element in the component, and position it relative to 0,0 inside the component.
+	for(var elementName in this.owningComponent.elements){
+		var element = this.owningComponent.elements[elementName];
+		//console.log("Processing element .."+element.type);
+		//console.log(element);
+		//console.log(this);
+	
+		var hint = element.hint;
+		
+		var width=element.getWidth();
+		var height=element.getHeight();
+        //console.log(" - element size was "+width+" x "+height);				
+      
+		//or something.. 
+		if(hint=="row"){
+			element.x=0;
+			element.y=currentYPos;
+			
+			//console.log("Invoking element.render");
+			
+			element.render();
+			
+			if(width>maxWidth){
+				maxWidth=width;
+			}
+
+			currentYPos+=rowPad;			
+			currentYPos+=height;
+						
+			//cant draw the sep line here, as the width of component isnt final yet.
+			sepYPos.push(currentYPos);
+
+		}else if(hint=="none"){
+			element.render();
+		}		
+	}
+	
+	//update comp width with maxWidth seen during element processing.
+	//console.log("Adjusting overall component dimensions");	
+	this.owningComponent.width=maxWidth;
+	this.owningComponent.height = currentYPos+yMargin;
+	
+	//now we know the width.. we can add our markup..
+	dojo.forEach(sepYPos, function(ypos){
+		//console.log("Adding sep line at "+ypos+" width "+this.owningComponent.width);
+		
+		//add separator line
+		this.layoutElements.createLine({x1:0, y1:ypos, x2: this.owningComponent.width, y2: ypos})
+		.setStroke({width:1, color: '#808080'});
+	},this);
+	
+	console.log("<doLayout");
+	
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/LayoutManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/LayoutManager.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/LayoutManager.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/LayoutManager.js Tue May 25 16:13:13 2010
@@ -0,0 +1,268 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.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 components 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 component name & version, not id.
+// load will only move components it is able to match, 
+// if a provider gives back different components 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("goat.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("goat.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 component_layouts_str = dojo.cookie("ozzy.demo.ui.layouts."+provider);
+		  if(component_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 component_layouts_str = dojo.cookie("ozzy.demo.ui.layouts."+provider);
+	  if(component_layouts_str!=null){
+		  var names = dojo.fromJson(component_layouts_str);
+		  console.log("Loaded for provider"+provider);
+		  console.log(component_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 component_coords = new Array();
+		var idx=0;
+		var coords_cookie="";
+		
+		var coord_data = new Array();
+		
+		dojo.forEach(components, function(component){
+			if(component!=null){
+				var x=component.x;
+				var y=component.y;		
+				var h=component.hidden ? 1 : 0;
+				var name=component.elements["component.property.SymbolicName"].value;
+				var version=component.elements["component.property.Version"].value;
+				
+				coord_data.push( {name:name, ver: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 component_coords_str = dojo.cookie("ozzy.demo.ui.coords."+providerSelector.getProvider()+"."+this.layoutSelector.attr('value'));
+		if(component_coords_str != null){
+			var component_coord_data = dojo.fromJson(component_coords_str);
+			dojo.forEach(component_coord_data, function(ci){
+				var id=-1;
+				dojo.forEach(components, function(c){ 
+						if(c!=null){
+							console.log(c);
+							console.log("Inside foreach");
+							var name=c.elements["component.property.SymbolicName"].value;
+							var version=c.elements["component.property.Version"].value;							
+							if((name==ci.name) && (version==ci.ver)){
+								id=c.id;
+							} 
+						}
+					});
+				
+				console.log("id "+id);
+				
+				//we may not know the component yet.. just ignore it for now.
+				if(components[id]!=null){				
+					components[id].x = ci.x;
+					components[id].y = ci.y;	
+					components[id].moveToNewPlace(ci.x, ci.y);					
+					var h2=components[id].hidden ? 1 : 0;
+					//	console.log("Bundle "+id+" had hidden flag of "+h+" ("+h2+") and current state of "+components[id].hidden);
+					if( ci.h!=h2 ){
+						//console.log("Flipping hidden state on component.."); 
+						components[id].toggleHidden();
+					}
+				}				
+			});
+
+			//dwr.util.setValue("coords_status", "Done");
+		}else{
+			//dwr.util.setValue("coords_status", "No cookie found");
+		}
+	}	
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ProviderSelector.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ProviderSelector.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ProviderSelector.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ProviderSelector.js Tue May 25 16:13:13 2010
@@ -0,0 +1,107 @@
+/**
+ * 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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.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 
+//     "goat.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("goat.ProviderSelector", [], {
+	
+	providerSelector:null,
+	whereProvider: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 components for prov");
+	ServerSideClass.getInitialComponents(this.getProvider());
+	console.log("Publishing provider change to "+provider);
+	dojo.publish("goat.provider.change",[provider]);
+},
+getProvider: function(){
+	return dijit.byId("ProviderSelector").value;
+},
+handleButton: function(){
+	this.notifyChangeOfProvider(this.getProvider());
+}
+		
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js Tue May 25 16:13:13 2010
@@ -0,0 +1,78 @@
+/**
+ * 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.
+ */
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.Relationship");
+dojo.require("goat.RelationshipElement");
+
+dojo.declare("goat.Relationship", [], {
+
+	key: null,
+	sscRelationship: null,
+	relationshipElements: null,
+
+constructor : function(sscRelationship) {
+	//keep this lightweight.. these can be created ONLY to get the key via the next method.. 
+	//all normal constructor logic lives in activate.
+	this.sscRelationship = sscRelationship;
+	this.relationshipElements=new Array();
+},
+getKey : function(){
+	if(this.key==null){
+		this.key="!"+this.sscRelationship.type+"!"+this.sscRelationship.name;
+	}
+	return this.key;
+},
+update : function(sscRelationship){
+	//console.log("Updating relationship "+this.key+" with new data");
+	
+	//console.log("Removing old elements..");
+    //remove the old relationship elements .. 
+	dojo.forEach(this.relationshipElements, function(relationshipElement){
+		relationshipElement.removeSelf();
+		//delete relationshipElement;
+	},this);
+	
+	//new array...
+	//console.log("forgetting about the removed relationship elts");
+	this.relationshipElements=new Array();
+	
+	//console.log("switching to the new sscRelationship...");
+	this.sscRelationship = sscRelationship;
+	
+	//console.log("kicking self to rebuild relationship elts");
+	this.activate();
+},
+activate : function(){
+	//create relationship element for each connection defined by this relationship.
+	//console.log(">activate");
+	dojo.forEach(this.sscRelationship.consumedBy, function(component){
+		//console.log("processing relationship prov by "+this.sscRelationship.providedBy.id+" to "+component.id);
+		
+		//surface, name, type, fromComponent, toComponent, aspects
+		var r = new goat.RelationshipElement(surface, this.sscRelationship.name, this.sscRelationship.type, components[this.sscRelationship.providedBy.id],components[component.id] );
+		//console.log("create of relationship element complete");
+		this.relationshipElements.push(r);
+		//hmm.. do we want to reverse-register the relationship like this?
+		//components[component.id].relationshipManager.registerRelationship(r);	
+	},this);	
+	//console.log(this.relationshipElements);
+	//console.log("<activate");
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipAggregator.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipAggregator.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipAggregator.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipAggregator.js Tue May 25 16:13:13 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.RelationshipAggregator");
+dojo.require("goat.Relationship");
+
+dojo.declare("goat.RelationshipAggregator", [], {
+
+		type: null,
+		relationships: null,
+		owningComponent: null,
+		
+		constructor : function(/*goat.Component*/owningComponent, type) {
+			this.type=type;
+			this.relationships=new Object();
+			this.owningComponent = owningComponent;
+			
+			//add this aggregation to the component.
+			var property = this.owningComponent.elementRegistry.getProperty(this.owningComponent, "relationship.aggregation."+this.type, this);
+			this.owningComponent.elements["relationship.aggregation."+this.type]=property;
+		},
+		add: function(/*goat.RelationshipElement*/relationship){
+			var key = this.getKeyForRelationship(relationship);
+			this.relationships[key] = relationship;
+			//console.log("Aggregator annoucing add to '"+"goat.relationshipaggregator.add."+this.owningComponent.id+"."+"relationship.aggregation."+this.type+"'");
+			dojo.publish("goat.relationshipaggregator.add."+this.owningComponent.id+"."+"relationship.aggregation."+this.type, [relationship]);
+		},
+		remove: function(/*goat.RelationshipElement*/relationship){
+			//console.log("RelationshipAggregator handling remove for..");
+			//console.log(relationship);
+			var key = this.getKeyForRelationship(relationship);
+			//console.log("RelationshipAggregator handling remove for "+key);
+			dojo.publish("goat.relationshipaggregator.remove."+this.owningComponent.id+"."+"relationship.aggregation."+this.type, [relationship]);
+			delete this.relationships[key];
+		},
+		getKeyForRelationship: function(/*goat.RelationshipElement*/relationship){
+			var key = ""+relationship.fromComponent.id+"!"+relationship.toComponent.id+"!"+relationship.name;
+			return key;
+		}
+			
+	});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipElement.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipElement.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipElement.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipElement.js Tue May 25 16:13:13 2010
@@ -0,0 +1,191 @@
+/**
+ * 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.
+ */
+dojo.provide("goat.RelationshipElement");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("goat.Component");
+
+//Relationship
+// represents a line between two components.
+//
+//TODO: 
+// - 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("goat.RelationshipElement", [], {	
+	
+	//relationship properties.
+	fromComponent: null,
+	toComponent: null,
+	name: null,	
+	type: null,
+	
+	//object properties	
+	surface: null,
+	visible: null,
+	typeOffset: 0,
+	
+	//gfx objects
+	line: null,
+	
+	//internals
+	stroke: null,
+	
+	//am I deleted?
+	removed: false,
+	
+	//for the up and coming relationship aspect info.. 
+	aspects: null,
+	
+	subs: null,
+	
+constructor: function(surface, name, type, fromComponent, toComponent, aspects) {
+	this.surface=surface;
+	
+	//console.log("Building relationship elt for "+name+" "+type+" from "+fromComponent.id+" to "+toComponent.id+" ");
+	
+	this.name=name;
+    this.type=type;
+	this.fromComponent=fromComponent;
+	this.toComponent=toComponent;
+	this.aspects=aspects;
+	
+	this.stroke = '#000000';
+    this.setStroke();
+	this.updateVisibility();
+	this.updateLine(); 
+		
+	this.subs=new Array();
+	this.subs.push(dojo.subscribe("goat.component.move."+fromComponent.id, this, this.onComponentMove));
+	this.subs.push(dojo.subscribe("goat.component.move."+toComponent.id, this, this.onComponentMove));
+	this.subs.push(dojo.subscribe("goat.component.hidden."+fromComponent.id, this, this.onComponentHidden));
+	this.subs.push(dojo.subscribe("goat.component.hidden."+toComponent.id, this, this.onComponentHidden));
+	this.subs.push(dojo.subscribe("goat.component.onclick."+toComponent.id, this, this.onComponentClick));
+	this.subs.push(dojo.subscribe("goat.component.onclick."+fromComponent.id, this, this.onComponentClick));
+	
+	//console.log("Publishing relationship create event");
+	dojo.publish("goat.relationship.create."+fromComponent.id,[this]);
+},
+setStroke: function(){	
+	
+	//right idea.. wrong approach.. this needs the registry to provide the renderer for this relationship type.
+	
+	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(){
+	if(this.removed){
+		//console.log("uv EEK.. this line should be dead.. and its aliiiiiive "+this.type+" from "+this.fromComponent.id+" to "+this.toComponent.id);
+		//console.log(this);
+	}
+	
+	this.visible = (!this.fromComponent.hidden) && (!this.toComponent.hidden);
+	
+	if(!this.visible){
+		if(this.line==null){
+			//console.log("adding line for relationship uv");
+			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.removed){
+		//console.log("ul EEK.. this line should be dead.. and its aliiiiiive "+this.type+" from "+this.fromComponent.id+" to "+this.toComponent.id);
+		//console.log(this);
+	}
+	
+	if(this.visible){
+		var fromx = this.fromComponent.x + (this.fromComponent.width / 2) + this.typeOffset;
+		var fromy = this.fromComponent.y + (this.fromComponent.height / 2)+ this.typeOffset;
+		var tox = this.toComponent.x + (this.toComponent.width / 2)+ this.typeOffset;
+		var toy = this.toComponent.y + (this.toComponent.height / 2)+ this.typeOffset;
+		if(this.line==null){
+			//console.log("adding line for relationship ul");
+			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.fromComponent.id+" to "+this.toComponent.id+" being removed");
+	//console.log(this);
+	if(!this.removed){
+		this.removed = true;
+		
+		//console.log("Line from "+this.fromComponent.id+" to "+this.toComponent.id+" being removed from surface");
+		this.surface.remove(this.line);
+		//console.log("Line from "+this.fromComponent.id+" to "+this.toComponent.id+" being marked as deleted");
+		
+		//console.log("Removing line subscriptions to components.");
+		dojo.forEach(this.subs, function(sub){
+			//console.log("unsubscribing.. ");
+			//console.log(sub);
+			dojo.unsubscribe(sub);
+		});
+		
+		this.subs = new Array();
+		
+		dojo.publish("goat.relationship.remove."+this.fromComponent.id,[this]);
+	}else{
+		console.log("Line from "+this.fromComponent.id+" to "+this.toComponent.id+" already marked as deleted");
+	}
+},
+getKey: function(){
+	var key = ""+this.fromComponent.id+"!"+this.toComponent.id+"!"+this.type+"!"+this.name;
+},
+onComponentMove: function(component){
+	this.updateLine();
+},
+onComponentHidden: function(component){
+	this.updateVisibility();
+},
+onComponentClick: function(component){
+	if(this.removed){
+		//console.log("occ EEK.. this line should be dead.. and its aliiiiiive "+this.type+" from "+this.fromComponent.id+" to "+this.toComponent.id);
+	}
+	
+	dojox.gfx.fx.animateStroke({
+	    shape: this.line,
+	    duration: 500,
+	    color: {start: "#FF3030", end: this.stroke},
+	    width: {start: 3, end: 2},
+	    join:  {values: ["miter", "bevel", "round"]}
+	}).play();	
+}
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipManager.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipManager.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/RelationshipManager.js Tue May 25 16:13:13 2010
@@ -0,0 +1,94 @@
+/**
+ * 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.
+ */
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.RelationshipManager");
+dojo.require("goat.RelationshipAggregator");
+dojo.require("goat.Component");
+dojo.require("goat.elements.ElementBase");
+dojo.require("goat.elements.ElementRegistry");
+
+dojo.declare("goat.RelationshipManager", [], {
+
+	               /*goat.Component*/ owningComponent: null,
+	/*goat.RelationshipAggregator[]*/   relationships: null,
+	createSub:null,
+	removeSub:null,
+
+constructor : function(/*goat.Component*/owningComponent) {
+	this.owningComponent = owningComponent;
+	this.relationships = new Array();
+	
+	dojo.subscribe("goat.relationship.create."+owningComponent.id, this, this.registerRelationship);
+	dojo.subscribe("goat.relationship.remove."+owningComponent.id, this, this.removeRelationship);
+},
+registerRelationship: function(/*goat.RelationshipElement*/relationship){	
+	//console.log(">registerRelationship");
+	//console.log(relationship);
+	var aggregator = this.relationships[relationship.type];
+	//console.log("aggregator..b4");
+	//console.log(aggregator);
+	if(aggregator==null){
+		//console.log("agg was null");
+		aggregator = new goat.RelationshipAggregator(this.owningComponent, relationship.type);
+		//console.log("adding aggregator");
+		this.relationships[relationship.type] = aggregator;
+	}
+	//console.log("aggregator..after");
+	//console.log(aggregator);
+	//console.log("adding to aggregator");
+	aggregator.add(relationship);	
+	//console.log("<registerRelationship");
+},
+removeRelationship: function(/*goat.RelationshipElement*/relationship){
+	//console.log("Relationship Manager for "+this.owningComponent.id+" handling removal for relationship..");
+	//console.log(relationship);
+	
+	var aggregator = this.relationships[relationship.type];
+	aggregator.remove(relationship);
+	
+	//was this the last relationship we knew about of this type?
+	//console.log("Checking if removal results in empty aggregator..");
+	var count=0;
+	for (var key in aggregator.relationships){
+		count++;
+	}
+	//console.log("Aggregator was managing "+count+" "+aggregator.relationships);
+	if(count==0){
+		//console.log("Last relationship found, removing.."+relationship.type);
+	
+		//remove from component..
+	    if(this.owningComponent.elements["relationship.aggregation."+relationship.type] !=null ){
+	    	
+	    	//console.log("Found relationship's renderer inside the component.. issuing remove to it");	    	
+	    	this.owningComponent.elements["relationship.aggregation."+relationship.type].remove();
+	    	
+	    	//console.log("Deleting it");
+			delete this.owningComponent.elements["relationship.aggregation."+relationship.type];
+		}
+
+	    //console.log("Forgetting about the aggregator");
+		delete this.relationships[relationship.type];
+	}
+},
+removeSelf: function(){
+	dojo.unsubscribe(this.createSub);
+	dojo.unsubscribe(this.removeSub);
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js Tue May 25 16:13:13 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.
+ */
+//callback from dwr, used to remove everything on a provider switch.
+function forgetAboutEverything(){
+	console.log("forgetting about everything.. ");
+	
+	dojo.forEach(relationships, function(relationship){
+		if(relationship!=null){
+			console.log("removing relationship "+relationship.getKey());
+			delete relationship;
+		}
+	});
+	relationships = new Array();
+	
+	dojo.forEach(components, function(component){
+		if(component!=null){
+			console.log("invoking removeself on "+component.id);
+			component.removeSelf();
+			delete component;
+		}
+	});
+	components = new Array();
+	
+
+	console.log("making sure absolutely..");
+	initialLayout.reset();
+}
+
+/**
+ * DWR Callback.<p>
+ * 
+ * Invoked to add or update a component.<br> 
+ * This method uses the component.id field to check if it already knows
+ * of the component, and either updates an existing one, or creates a 
+ * new one depending on the result.<p>
+ * 
+ * Updating a component can add, or modify component properties, but 
+ * currently cannot delete them.<p>
+ * 
+ * Children are placeholders still.
+ */
+function addComponent(component) {
+    console.log("******************* Component data **************");
+	
+	//if we dont know about the id yet, setup a new component.
+	if (components[component.id] == null) {
+		//create the component display object			
+		components[component.id] = new goat.Component( surface, component.id, component.componentProperties);
+
+		//put it somewhere sensible.
+		initialLayout.placeComponent(components[component.id]);
+	} else {
+		console.log("Updating component "+component.id);
+		//otherwise, we knew about the component, so update it.
+		components[component.id].update(component.id, component.componentProperties);			
+	}	
+	//console.log("Done adding component");
+}
+
+//callback from dwr
+function addRelationship(relationship) {
+	console.log("******************* Relationship data **************");
+	console.log(relationship);
+	
+	var r=new goat.Relationship(relationship);
+	var key=r.getKey();
+	
+	console.log("checking relationship store for "+key);
+	
+	if(relationships[key]!=null){
+		console.log("Found, issuing update");
+		relationships[key].update(relationship);
+	}else{
+		console.log("Not found, creating new..");
+		relationships[key]=r;
+		//because we use getKey to test the existence, the constructor for 
+		//Relationship is lazy, and we need to kick the instance to tell it
+		//we actually plan to use it.		
+		r.activate();
+	}
+}
+
+//call back from componentstatusgrid to hide component.. //TODO: see if this can be made unglobal.
+function hideComponent(id){
+    components[id].toggleHidden();
+}

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/SimpleInitialLayout.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/SimpleInitialLayout.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/SimpleInitialLayout.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/SimpleInitialLayout.js Tue May 25 16:13:13 2010
@@ -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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.SimpleInitialLayout");
+
+dojo.declare("goat.SimpleInitialLayout", [], {
+	lastCreatedX:0,
+	lastCreatedY:0,
+	lastCreatedWidth:0,
+	lastCreatedHeight:0,
+	surfaceX:0,
+	surfaceY:0,
+	constructor: function(x,y){
+		this.surfaceX=x;
+		this.surfaceY=y;
+	},
+	placeComponent: function(component){
+		//Move the new bundle so it appears in a nice way
+		var end = this.lastCreatedX + this.lastCreatedWidth + 5;
+		if (end + component.width < this.surfaceX) {
+			component.moveToNewPlace(end, this.lastCreatedY);
+		} else {
+			if ((this.lastCreatedY + this.lastCreatedHeight + 5) < this.surfaceY) {
+				component.moveToNewPlace(5, (this.lastCreatedY
+						+ this.lastCreatedHeight + 5));		
+			}			
+		}	
+		this.lastCreatedX = component.x;
+		this.lastCreatedWidth = component.width;
+		this.lastCreatedY = component.y;
+		this.lastCreatedHeight = component.height;		
+	},
+	reset: function(){
+		this.lastCreatedX=0;
+		this.lastCreatedY=0;
+		this.lastCreatedWidth=0;
+		this.lastCreatedHeight=0;		
+	}
+			
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/TwistieSection.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/TwistieSection.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/TwistieSection.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/TwistieSection.js Tue May 25 16:13:13 2010
@@ -0,0 +1,207 @@
+/**
+ * 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.
+ */
+dojo.provide("goat.TwistieSection");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+//TwistieSection
+// Manages expandable content within a component.
+//
+// TODO:
+//  - update renderer to cope with massive content, ie bundle 0 exports)
+//    - 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("goat.TwistieSection", [], {
+	
+	//object properties	
+	parentGroup: null,
+	owningComponent: 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, owningComponent, x, y, getItemsCallBack) {
+	this.surface=surface;
+	this.name=name;
+	this.parentGroup=parentGroup;
+	this.owningComponent=owningComponent;
+	this.x=x;
+	this.y=y;
+	this.isOpen=false;
+	this.getItemsCallback = getItemsCallBack;
+	this.width=150;
+	this.height=12;
+
+	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 + 10;
+	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){
+	//console.log("Updating twisty xy to "+x+","+y);
+	//console.log("Before the move, I have size of "+this.width+" x "+this.height);
+	
+	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();
+	
+	//console.log("After the move, I have size of "+this.width+" x "+this.height);
+},
+removeItemsFromDisplay: function(){
+	var _this = this;
+	if(this.itemTexts!=null){
+		dojo.forEach( this.itemTexts , function(t){
+			_this.twistieGroup.remove(t);	
+		});
+	}
+	this.height = 12;
+	this.width = 150;
+},
+addItemsToDisplay: function(){
+	var maxLengthSeen = 0;
+	var extraHeight = 12;
+	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.owningComponent.minWidth;				
+	if(maxLengthSeen>25){
+		var extraW = maxLengthSeen-25;
+		extraW = extraW * 6;
+		extraWidth = extraWidth + extraW;
+	}
+	
+	if(extraWidth<this.width){
+		extraWidth = this.owningComponent.width;
+	}
+	
+	//console.log("maxLenSeen "+maxLengthSeen+" minWidht "+this.owningComponent.minWidth);
+	
+	//console.log("after adding items to display, twistie is now "+extraHeight+" x "+extraWidth);
+	
+	this.height = extraHeight;
+	this.width = extraWidth;
+},
+twistieHandler: function() {
+	
+	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();
+	}
+	console.log("twistie requesting refresh of component due to change in state/content");
+	this.owningComponent.refresh();	
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorProperty.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorProperty.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorProperty.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorProperty.js Tue May 25 16:13:13 2010
@@ -0,0 +1,54 @@
+/**
+ * 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.
+ */
+//dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.elements.ComponentColorProperty");
+
+dojo.declare("goat.elements.ComponentColorProperty", [goat.elements.ElementBase], {
+
+	value: null,
+
+constructor : function(component, /*String*/ type, /*String*/ value) {
+	this.component=component;
+	this.value=value;
+	this.type=type;
+	this.hint="none";
+},
+getWidth: function() {
+	return 0;
+},
+getHeight: function() {
+	return 0;
+},
+render: function(){
+	if(this.type=="component.property.State"){
+		if(this.value!="ACTIVE"){
+			//nasty reading directly into the comp like this, but it will do for now.
+			this.component.outline.setFill({type: "linear",  x1: 0, y1: 0, x2: 150, y2: 80,
+				colors: [{ offset: 0, color: "#808080" },{ offset: 1, color: "#ffffff" } ]});
+		}
+	}	
+},
+update: function(value){
+	this.value=value;
+},
+remove: function(){
+	//no op, we only exist due to the color of the owning component..
+}
+
+});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js Tue May 25 16:13:13 2010
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.elements.ComponentContainer");
+
+dojo.declare("goat.elements.ComponentContainer", goat.elements.ElementBase, {
+
+	    /*goat.Component[]*/children:null,
+	
+		constructor : function(component, type, /*goat.Component[]*/children) {
+		    this.component=component;
+			this.type=type;
+			this.children=children;
+		},
+		getWidth : function() {
+			return 250;
+		},
+		getHeight : function() {
+			return 250;
+		},
+		update: function(children){
+			//TODO: better children merging.. handle add/remove/modify
+			this.children=children;
+		},
+		remove: function(){
+			
+		}
+			
+	});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js Tue May 25 16:13:13 2010
@@ -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.
+ */
+// dojo.provide allows pages use all types declared in this resource
+dojo.provide("goat.elements.ElementBase");
+
+dojo.declare("goat.elements.ElementBase", [], {
+	
+	    type: null,
+	    component: null,
+	    x: 0,
+	    y: 0,
+		width: 0,
+		height: 0,
+		hint: "top",
+
+		constructor : function(component) {
+			//not really called (naughty sub-classes dont chain their constructors..)
+	        
+	        //DO NOT put things onscreen during the constructor, delay that until 'render' is invoked if possible.
+		},
+		update: function(/*Object*/ value){
+			//called to tell this element, that its value should be updated to the passed arg.
+		},
+		getWidth: function() {
+			//called to obtain the width of this element for layout purposes
+			return -1;
+		},
+		getHeight: function() {
+			//called to obtain the height of this element for layout purposes
+			return -1;
+		},
+		render: function() {
+			//called to add this element to the screen at this.x, this.y
+		},
+		remove: function() {
+			//called to remove this element from the screen
+		}
+		
+			
+	});

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js?rev=948087&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js (added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js Tue May 25 16:13:13 2010
@@ -0,0 +1,63 @@
+/**
+ * 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.
+ */
+//dojo.provide allows pages use all types declared in this resource
+
+var /*goat.elements.ElementRegistry */ registry=null;
+
+dojo.provide("goat.elements.ElementRegistry");
+
+dojo.require("goat.elements.TextComponentProperty");
+dojo.require("goat.elements.ComponentContainer");
+dojo.require("goat.elements.RelationshipAggregation");
+dojo.require("goat.elements.ComponentColorProperty");
+
+dojo.declare("goat.elements.ElementRegistry", [], {
+	
+constructor : function() {
+	if(registry==null){
+		registry = this;
+	}
+},
+
+//getRegistry returns the appropriate registry for the component passed. 
+/*goat.elements.ComponentPropertyRegistry */ getRegistry : function(/*goat.Component*/ component, props) {
+	
+	//we currently just have the one.
+	//we might start to tailor this, perhaps if we want totally different rendering rules per component, or component type.
+	
+	return registry;
+},
+
+/*goat.elements.ElementBase*/ getProperty : function(component, /*String*/type, /*Object*/value){
+	
+	//this sort of resolution needs to be handled by Config.
+	if(type=="component.property.State"){
+		return new goat.elements.ComponentColorProperty(component,type,value);
+	}else if(type.match("^component.property.")=="component.property."){
+		return new goat.elements.TextComponentProperty(component,type,value);
+	}else if(type.match("^component.container")=="component.container"){
+		return new goat.elements.ComponentContainer(component, type, value);
+	}else if(type.match("^relationship.aggregation.")=="relationship.aggregation."){
+		return new goat.elements.RelationshipAggregation(component, type, value);
+	}
+	//else.. unknown property.. ignore it.
+}
+
+
+});



Mime
View raw message