incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r960170 - in /incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat: ./ elements/
Date Sat, 03 Jul 2010 08:37:33 GMT
Author: zoe
Date: Sat Jul  3 08:37:33 2010
New Revision: 960170

URL: http://svn.apache.org/viewvc?rev=960170&view=rev
Log:
ARIES-319 Merging elements/TwistieAggregation and TwistieSection into elements/TwistieSection-
first pass. 

Added:
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieSection.js
Removed:
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/TwistieSection.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieAggregation.js
Modified:
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorElement.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js
    incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TextComponentProperty.js

Modified: 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=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js (original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Component.js Sat
Jul  3 08:37:33 2010
@@ -168,7 +168,8 @@ removeSelf : function() {
 	this.surface.remove(this.group);
 	//Now we remove all other the elements
 	for (var type in this.elements) {
-		this.elements[type].remove();
+		console.log("Removing element of type : " + type);
+		this.elements[type].removeSelf();
 		delete this.elements[type];
 	}
 	this.relationshipManager.removeSelf();

Modified: 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=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ElementLayoutManager.js
Sat Jul  3 08:37:33 2010
@@ -78,7 +78,7 @@ doLayout: function(){	
 			element.x=0;
 			element.y=currentYPos;
 			
-			//console.log("Invoking element.render");
+			console.log("Invoking element.render" + this.owningComponent.id + " " + elementName);
 			
 			element.render();
 			

Modified: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorElement.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorElement.js?rev=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorElement.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentColorElement.js
Sat Jul  3 08:37:33 2010
@@ -62,7 +62,7 @@ dojo
 					update : function(value) {
 						this.value = value;
 					},
-					remove : function() {
+					removeSelf : function() {
 						// no op, we only exist due to the color of the owning
 						// component..
 				}

Modified: 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=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ComponentContainer.js
Sat Jul  3 08:37:33 2010
@@ -38,7 +38,7 @@ dojo.declare("goat.elements.ComponentCon
 			//TODO: better children merging.. handle add/remove/modify
 			this.children=children;
 		},
-		remove: function(){
+		removeSelf: function(){
 			
 		}
 			

Modified: 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=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementBase.js
Sat Jul  3 08:37:33 2010
@@ -55,7 +55,7 @@ dojo.declare("goat.elements.ElementBase"
 		render: function() {
 			//called to add this element to the screen at this.x, this.y
 		},
-		remove: function() {
+		removeSelf: function() {
 			//called to remove this element from the screen
 		}
 		

Modified: 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=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/ElementRegistry.js
Sat Jul  3 08:37:33 2010
@@ -24,7 +24,7 @@ dojo.provide("goat.elements.ElementRegis
 
 dojo.require("goat.elements.TextComponentProperty");
 dojo.require("goat.elements.ComponentContainer");
-dojo.require("goat.elements.TwistieAggregation");
+dojo.require("goat.elements.TwistieSection");
 dojo.require("goat.elements.ComponentColorElement");
 
 dojo.require("goat.configuration.ComponentAppearance");
@@ -57,7 +57,7 @@ constructor : function() {
 	}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.TwistieAggregation(component, type, value);
+		return new goat.elements.TwistieSection(component, type, value);
 	}
 	//else.. unknown property.. ignore it.
 }

Modified: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TextComponentProperty.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TextComponentProperty.js?rev=960170&r1=960169&r2=960170&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TextComponentProperty.js
(original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TextComponentProperty.js
Sat Jul  3 08:37:33 2010
@@ -61,7 +61,7 @@ dojo.declare("goat.elements.TextComponen
 		update: function(value){
 			this.value=value;
 		},
-		remove: function(){
+		removeSelf: function(){
 			if(this.text!=null){
 				this.component.group.remove(this.text);
 			}			

Added: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieSection.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieSection.js?rev=960170&view=auto
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieSection.js
(added)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/TwistieSection.js
Sat Jul  3 08:37:33 2010
@@ -0,0 +1,205 @@
+/**
+ * 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.
+ */
+// TwistieSection is responsible for creating and renedring the twistie element. It draws
the trinagle at 
+// x,y coordinate supplied by the owning component. It diplays lines of text derived from
a 
+// relationship aggregator if the twistie is open and removes them from display when the
twistie
+// is closed.
+dojo.provide("goat.elements.TwistieSection");
+dojo.require("goat.elements.ElementBase");
+dojo.require("goat.RelationshipAggregator");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("dojo.data.ItemFileWriteStore");
+
+
+dojo.declare("goat.elements.TwistieSection", goat.elements.ElementBase, {
+
+		/*goat.RelationshipAggregator*/ content: null,
+		group: null,
+		addsub: null,
+		removesub: null,
+		
+		built: false,
+		
+		constructor : function(component, /*String*/ type, /*goat.RelationshipAggregator*/ content)
{
+	        
+	        this.component=component;
+			this.type=type;
+			this.content=content;
+			this.x = 0;
+			this.y = 0;
+			this.hint="row";
+			this.width=150;
+			this.height=12;
+			this.isOpen=false;
+			//maintains a list of relations ships to displsy - with dups removed.
+			this.items = new Array();
+			this.itemTexts = new Array();
+
+
+			this.twistieGroup = this.component.group.createGroup();
+			this.component.group.remove(this.twistieGroup);
+    		this.twistieHandleGroup = this.twistieGroup.createGroup();
+	
+			this.twistieHandleGroup.connect("onclick",dojo.hitch(this,"twistieHandler"));
+			
+			console.log("ZZX: New TA instance, type: " + type + " component: " + this.component.id);

+
+			this.addsub=dojo.subscribe("goat.relationshipaggregator.add."+this.component.id+"."+this.type,
this, this.onAdd);
+			this.removesub=dojo.subscribe("goat.relationshipaggregator.remove."+this.component.id+"."+this.type,
this, this.onRemove);		
+		},
+		getContent : function(){
+			return this.content;
+		},
+		getWidth : function(){
+			return this.width;
+		},
+		getHeight: function(){
+			return this.height;
+		},
+		render: function(){
+			console.log("RENDERING...");
+			this.component.group.remove(this.twistieGroup);
+			if(this.built) {this.twistieHandleGroup.remove(this.twistieHandle);}
+
+			this.createTwistie();
+			this.component.group.add(this.twistieGroup);
+			console.log("Rendered, x = " + this.x + "y = " + this.y);
+		},
+		update: function(value){
+		},
+		remove: function(value){
+			this.component.group.remove(this.twistieGroup);
+			dojo.unsubscribe(this.addsub);
+			dojo.unsubscribe(this.removesub);
+
+		},		
+		onAdd: function(/*RelationshipElement[]*/args){
+			if(!this.inArray(this.items, args.name)) {
+					this.items.push(args.name);
+			}
+			if (!this.built) {
+				this.component.refresh();
+				this.built = true;
+			}
+			if (this.isOpen) {
+				this.addItemsToDisplay();
+				this.component.refresh();
+			}
+
+		}, 
+		onRemove: function(/*RelationshipElement[]*/args){
+			for(var k in this.items) {
+				if(this.items[k] == args.nam) {
+					delete this.items[k];
+				}
+			}
+			if(this.isOpen) {
+				this.addItemsToDisplay;
+				this.component.refresh();
+			}
+		}, 
+		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;
+
+        		this.removeItemsFromDisplay();
+        		for(idx=0; idx<this.items.length; idx++){
+            		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;
+                		}
+            		}
+        		}
+    		}
+
+    		var extraWidth = this.component.minWidth;
+    		if(maxLengthSeen>25){
+        		var extraW = maxLengthSeen-25;
+        		extraW = extraW * 6;
+        		extraWidth = extraWidth + extraW;
+    		}
+
+    		if(extraWidth<this.width){
+        		extraWidth = this.component.width;
+    		}
+
+    		this.height = extraHeight;
+    		this.width = extraWidth;
+		},
+
+		removeItemsFromDisplay: function(){
+    		if(this.itemTexts!=null){
+				for (var k in this.itemTexts) {
+					this.twistieGroup.remove(this.itemTexts[k]);
+    			}
+    			this.height = 12;
+    			this.width = 150;
+			}
+		},
+		twistieHandler: function() {
+    		this.isOpen=!this.isOpen;
+
+    		this.twistieHandleGroup.remove(this.twistieHandle);
+    		this.createTwistie();
+
+    		if(this.isOpen){
+            	this.addItemsToDisplay();
+    		}else{
+        		this.removeItemsFromDisplay();
+    		}
+    		console.log("twistie requesting refresh of component due to change in state/content");
+    		this.component.refresh();
+		},
+		createTwistie: function(){
+			console.log("in create twistie, x = " + this.x + " y = " + this.y);
+    		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}]).setFill("#000000");
+
+    		if(this.isOpen){
+        		this.twistieHandle.setShape([{x:px,y:pys},{x:pxe,y:pys},{x:pxm,y:pye}]);
+    		}
+		},
+		inArray: function(a, string) {
+			for (var k in a) {
+				if(a[k] == string) {
+					return true;
+				}
+			}
+			return false;
+		}
+
+
+});



Mime
View raw message