You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by zo...@apache.org on 2010/06/19 22:26:21 UTC
svn commit: r956288 - in
/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat:
Component.js Relationship.js ServerSideInterface.js
elements/ElementRegistry.js elements/RelationshipElement.js
Author: zoe
Date: Sat Jun 19 20:26:20 2010
New Revision: 956288
URL: http://svn.apache.org/viewvc?rev=956288&view=rev
Log:
ARIES-319 Completed fix for provider switch (component delete path)
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/Relationship.js
incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.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/RelationshipElement.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=956288&r1=956287&r2=956288&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 Jun 19 20:26:20 2010
@@ -174,7 +174,7 @@ removeSelf : function() {
this.relationshipManager.removeSelf();
delete this.RelationshipManager;
- //This one is subscribed to by RelationshipElement
+ //This one is subscribed to by Relationship
dojo.publish("goat.component.delete." + this.id, [ this ]);
//This one is subscribed to by ComponentStatusGrid
Modified: 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=956288&r1=956287&r2=956288&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js (original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/Relationship.js Sat Jun 19 20:26:20 2010
@@ -16,11 +16,17 @@
* 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.elements.RelationshipElement");
dojo.require("goat.elements.TriangleDecorator");
+/* Relationship represents a relationship which is provided by one component but may be
+ * consumed by many. For example a package which is exported by component (bundle) A
+ * may be imported by components B, C, D...etc. Each two way relationship is represented
+ * by a RelationshipElement, for example A-B, A-C. Relationship maintains a list of
+ * RelationshipElements.
+ */
+
dojo.declare("goat.Relationship", [], {
key: null,
@@ -29,11 +35,13 @@ dojo.declare("goat.Relationship", [], {
theme: null,
constructor : function(sscRelationship, theme) {
- //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();
this.theme = theme;
+ this.subs = new Array();
+
+ //Subscribe to providing component deletion
+ this.providerSubs = dojo.subscribe("goat.component.delete." + this.sscRelationship.providedBy.id, this, this.removeSelf);
},
getKey : function(){
if(this.key==null){
@@ -42,58 +50,57 @@ getKey : function(){
return this.key;
},
update : function(sscRelationship){
- console.log("Updating relationship "+this.key+" with new data");
-
- console.log("Removing old elements..");
- console.log(this.relationshipElements);
+
//remove the old relationship elements ..
- dojo.forEach(this.relationshipElements, function(relationshipElement){
- console.log("Removing.. ");
- console.log(relationshipElement);
- relationshipElement.removeSelf();
- //delete relationshipElement;
- },this);
-
- //new array...
- console.log("forgetting about the removed relationship elts");
+ for(var index in this.relationshipElements) {
+ this.relationshipElements[index].removeSelf();
+ }
+
this.relationshipElements=new Array();
- console.log("switching to the new sscRelationship...");
this.sscRelationship = sscRelationship;
- console.log("kicking self to rebuild relationship elts");
this.activate();
},
+removeElement : function(component) {
+ this.relationshipElements[component.id].removeSelf();
+ delete this.relationshipElements[component.id];
+ dojo.unsubscribe(this.subs[component.id]);
+},
+removeSelf : function() {
+ for(var index in this.relationshipElements) {
+ this.relationshipElements[index].removeSelf();
+ }
+ dojo.unsubscribe(this.providerSubs);
+},
activate : function(){
- //console.log(">activate");
-
- //Create a relationship element for each consuming component. Use the consuming component because it's
- //a 1:1 relationship whereas the providing component may provide the element to many different consuming
- //components.
-
+ /*
+ * Create a relationship element for each consuming component. Use the consuming component because it's
+ * a 1:1 relationship whereas the providing component may provide the element to many different consuming
+ * components.
+ */
dojo.forEach(this.sscRelationship.consumedBy, function(component){
- //console.log("processing relationship prov by "+this.sscRelationship.providedBy.id+" to "+component.id);
- var r = new goat.elements.RelationshipElement(surface, this.sscRelationship.name, this.sscRelationship.type, components[this.sscRelationship.providedBy.id],components[component.id] );
+ var relationshipElement = new goat.elements.RelationshipElement(surface,
+ this.sscRelationship.name, this.sscRelationship.type,
+ components[this.sscRelationship.providedBy.id],components[component.id] );
- //console.log("type is " + this.sscRelationship.type);
//Add a service decorator if it is a service relationship
if (this.sscRelationship.type == "serviceExport") {
- r.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
} else if (this.sscRelationship.type == "serviceImport") {
- r.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
} else if (this.sscRelationship.type == "Service") {
- r.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
}
- //console.log("create of relationship element complete");
- this.relationshipElements.push(r);
+ //Add the relationship to a list and subscript to the deletion of the consuming component
+ this.relationshipElements[component.id] = relationshipElement;
+ this.subs[component.id] = dojo.subscribe("goat.component.delete." + component.id, this, this.removeElement);
+
},this);
- //console.log(this.relationshipElements);
- //console.log("<activate");
}
-
});
Modified: 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=956288&r1=956287&r2=956288&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js (original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/ServerSideInterface.js Sat Jun 19 20:26:20 2010
@@ -37,7 +37,6 @@ function forgetAboutEverything(){
var relationship = relationships[relationshipNumber];
if(relationship!=null){
- console.log("removing relationship "+relationship.getKey());
delete relationship;
}
}
@@ -86,13 +85,12 @@ function addRelationship(relationship) {
var r=new goat.Relationship(relationship, theme);
var key=r.getKey();
- console.log("checking relationship store for "+key);
+ //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
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=956288&r1=956287&r2=956288&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 Jun 19 20:26:20 2010
@@ -51,7 +51,6 @@ constructor : function() {
// TODO fill in the rest of the arguments to the other elements
//this sort of resolution needs to be handled by Config.
if(type=="component.property.State"){
- console.log("constructing with " + value)
return new goat.elements.ComponentColorElement(component, componentAppearance, type,value);
}else if(type.match("^component.property.")=="component.property."){
return new goat.elements.TextComponentProperty(component,type,value);
Modified: incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/RelationshipElement.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/RelationshipElement.js?rev=956288&r1=956287&r2=956288&view=diff
==============================================================================
--- incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/RelationshipElement.js (original)
+++ incubator/aries/trunk/samples/goat/goat-web/src/main/resources/web/goat/elements/RelationshipElement.js Sat Jun 19 20:26:20 2010
@@ -82,30 +82,21 @@ constructor: function(surface, name, typ
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));
- // When a component is resized teh relationship line needs to be re-drawn.
+ // When a component is resized the relationship line needs to be re-drawn.
this.subs.push(dojo.subscribe("goat.component.resize."+fromComponent.id, this, this.onComponentResize));
this.subs.push(dojo.subscribe("goat.component.resize."+toComponent.id, this, this.onComponentResize));
- // When a component is deleted remove myself
- this.subs.push(dojo.subscribe("goat.component.delete."+fromComponent.id, this, this.removeSelf));
- this.subs.push(dojo.subscribe("goat.component.delete."+toComponent.id, this, this.removeSelf));
-
- this.decorators = new Array();
-
- console.log("Publishing relationship create to event", fromComponent.id, toComponent.id);
dojo.publish("goat.relationship.create."+fromComponent.id,[this]);
dojo.publish("goat.relationship.create."+toComponent.id,[this]);
+ this.decorators = new Array();
+
},
addDecorator: function(decorator) {
decorator.setStroke(this.stroke);
this.decorators.push(decorator);
},
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);
- //}
// Visible will be 'true' only if both componenets are not hidden (ie visible)
this.visible = (!this.fromComponent.hidden) && (!this.toComponent.hidden);
@@ -117,7 +108,6 @@ updateVisibility: function(){
//console.log("Hiding decorators..");
dojo.forEach(this.decorators, function(decorator){
- //console.log("Hiding decorator..");
decorator.makeInvisible();
},this);
@@ -127,13 +117,8 @@ updateVisibility: function(){
}
},
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){
- //console.log("Updating VISIBLE line from "+this.fromComponent.id+" to "+this.toComponent.id);
var fromx = this.fromComponent.x + (this.fromComponent.width / 2);
var fromy = this.fromComponent.y + (this.fromComponent.height / 2);
var tox = this.toComponent.x + (this.toComponent.width / 2);
@@ -158,49 +143,34 @@ updateLine: function(){
},
removeSelf: function(){
- console.log("Z: Line from "+this.fromComponent.id+" to "+this.toComponent.id+" being removed");
- //console.log(this);
if(!this.removed){
this.removed = true;
- //console.log("Z: Line from "+this.fromComponent.id+" to "+this.toComponent.id+" being removed from surface");
- //console.log(this);
if(this.line!=null) {
this.surface.remove(this.line);
}
- //console.log("Z: Removing decorators..");
dojo.forEach(this.decorators, function(decorator){
- //console.log("Asking...");
- //console.log(decorator);
- //console.log("..to remove itself");
decorator.removeSelf();
});
this.decorators = new Array();
- //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();
if(this.fromComponent.id != this.toComponent.id) {
- //console.log("Z:RelationshipElement - publishing to this that I'm gone", this.fromComponent.id);
dojo.publish("goat.relationship.remove."+this.fromComponent.id,[this]);
-
- //console.log("Z:RelationshipElement - publishing to this that I'm gone", this.toComponent.id);
dojo.publish("goat.relationship.remove."+this.toComponent.id,[this]);
} else {
- console.log("Z:RelationshipElement - publishing to this that I'm gone", this.toComponent.id);
dojo.publish("goat.relationship.remove."+this.toComponent.id,[this]);
}
}else{
- console.log("Line from "+this.fromComponent.id+" to "+this.toComponent.id+" already marked as deleted");
+ //console.log("Line from "+this.fromComponent.id+" to "+this.toComponent.id+" already marked as deleted");
}
},
getKey: function(){
@@ -216,10 +186,6 @@ onComponentHidden: function(component){
this.updateVisibility();
},
onComponentClick: function(component){
- //console.log("OnClick "+component.id);
- 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);
- }
if(this.line!=null) {
dojox.gfx.fx.animateStroke({