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/10/30 17:42:41 UTC
svn commit: r1029102 [4/5] - in
/incubator/aries/trunk/samples-sandbox/dgoat: ./ dgoat-api/ dgoat-api/src/
dgoat-api/src/main/ dgoat-api/src/main/java/ dgoat-api/src/main/java/org/
dgoat-api/src/main/java/org/apache/ dgoat-api/src/main/java/org/apache/...
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/LayoutManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/LayoutManager.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/LayoutManager.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/LayoutManager.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,275 @@
+/**
+ * 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();
+
+ for (var componentNumber in components) {
+ var component = components[componentNumber];
+ console.log("In save coords");
+ console.log(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;
+ for (var componentNumber in components) {
+ var c = components[componentNumber];
+ 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-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ProviderSelector.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ProviderSelector.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ProviderSelector.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ProviderSelector.js Sat Oct 30 15:42:36 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-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Relationship.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Relationship.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Relationship.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Relationship.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,106 @@
+/**
+ * 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.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,
+ sscRelationship: null,
+ relationshipElements: null,
+ theme: null,
+
+constructor : function(sscRelationship, theme) {
+ 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){
+ this.key="!"+this.sscRelationship.type+"!"+this.sscRelationship.name;
+ }
+ return this.key;
+},
+update : function(sscRelationship){
+
+ //remove the old relationship elements ..
+ for(var index in this.relationshipElements) {
+ this.relationshipElements[index].removeSelf();
+ }
+
+ this.relationshipElements=new Array();
+
+ this.sscRelationship = sscRelationship;
+
+ 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(){
+ /*
+ * 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){
+
+ var relationshipElement = new goat.elements.RelationshipElement(surface,
+ this.sscRelationship.name, this.sscRelationship.type,
+ components[this.sscRelationship.providedBy.id],components[component.id] );
+
+ //Add a service decorator if it is a service relationship
+ if (this.sscRelationship.type == "serviceExport") {
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+
+ } else if (this.sscRelationship.type == "serviceImport") {
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+
+ } else if (this.sscRelationship.type == "Service") {
+ relationshipElement.addDecorator(new goat.elements.TriangleDecorator(this.theme,surface));
+ }
+
+
+ //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);
+}
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipAggregator.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipAggregator.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipAggregator.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipAggregator.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,59 @@
+/**
+ * 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,
+ componentAppearance: null,
+
+ constructor : function(/*goat.Component*/owningComponent, type) {
+ this.type=type;
+ this.relationships=new Object();
+ this.owningComponent = owningComponent;
+ this.componentAppearance = owningComponent.getComponentAppearance();
+
+ //add this aggregation to the component.
+ var property = this.owningComponent.elementRegistry.getProperty(this.owningComponent, this.componentAppearance, "relationship.aggregation."+this.type, this);
+ this.owningComponent.elements["relationship.aggregation."+this.type]=property;
+ },
+ add: function(/*goat.elements.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.elements.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.elements.RelationshipElement*/relationship){
+ var key = ""+relationship.fromComponent.id+"!"+relationship.toComponent.id+"!"+relationship.name;
+ return key;
+ }
+
+ });
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipManager.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipManager.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipManager.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/RelationshipManager.js Sat Oct 30 15:42:36 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();
+
+ this.createSub = dojo.subscribe("goat.relationship.create."+owningComponent.id, this, this.registerRelationship);
+ this.removeSub = dojo.subscribe("goat.relationship.remove."+owningComponent.id, this, this.removeRelationship);
+},
+registerRelationship: function(/*goat.elements.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.elements.RelationshipElement*/relationship){
+ //console.log("Z: RelationshipManager "+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].removeSelf();
+
+ //console.log("Deleting it");
+ delete this.owningComponent.elements["relationship.aggregation."+relationship.type];
+ }
+
+ //console.log("Z: Realtionship manager: Forgetting about the aggregator");
+ delete this.relationships[relationship.type];
+ }
+},
+removeSelf: function(){
+ dojo.unsubscribe(this.createSub);
+ dojo.unsubscribe(this.removeSub);
+}
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ServerSideInterface.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ServerSideInterface.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ServerSideInterface.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/ServerSideInterface.js Sat Oct 30 15:42:36 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.
+ */
+//callback from dwr, used to remove everything on a provider switch.
+
+function forgetAboutEverything(){
+ console.log("forgetting about everything.. ");
+
+
+ for (var componentNumber in components) {
+ var component = components[componentNumber];
+ if(component!=null){
+ console.log("invoking removeself on "+component.id);
+ component.removeSelf();
+ delete component;
+ }
+ }
+ components = new Array();
+
+
+ for (var relationshipNumber in relationships) {
+ var relationship = relationships[relationshipNumber];
+
+ if(relationship!=null){
+ delete relationship;
+ }
+ }
+ relationships = 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
+ // pass in null for the children for the moment
+ components[component.id] = new goat.Component( surface, component.id, component.componentProperties, null, theme);
+
+ //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, theme);
+ 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{
+ 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){
+ console.log("Hiding or showing component");
+ console.log(components[id]);
+ components[id].toggleHidden();
+}
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/SimpleInitialLayout.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/SimpleInitialLayout.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/SimpleInitialLayout.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/SimpleInitialLayout.js Sat Oct 30 15:42:36 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-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/ComponentAppearance.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/ComponentAppearance.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/ComponentAppearance.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/ComponentAppearance.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,108 @@
+/**
+ * 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.configuration.ComponentAppearance");
+
+dojo.require("goat.configuration.Theme");
+
+dojo.declare("goat.configuration.ComponentAppearance", [], {
+
+ parentAppearance : null,
+
+ theme : null,
+
+ fontFamily : null,
+ fontStretch : null,
+ textFill : null,
+ lineStyle : null,
+ lineColour : null,
+ lineWidth : null,
+ backgroundColour : null,
+ backgroundContrastColour : null,
+ outlineColor0 : null,
+ outlineColor1 : null,
+ outlineColor2 : null,
+
+ constructor : function(theme, parentAppearance) {
+ this.theme = theme;
+ this.parentAppearance = parentAppearance;
+ },
+ getBackgroundColor : function() {
+ if (this.backgroundColor != null) {
+ return this.backgroundColor;
+ } else if (this.parentAppearance != null) {
+ return parentAppearance.getBackgroundColor();
+ } else {
+ return this.theme.getBundleBackgroundColor();
+ }
+ },
+ getOutlineColor0 : function() {
+ if (this.outlineColor0 != null) {
+ return this.outlineColor0;
+ } else if (this.parentAppearance != null) {
+ return parentAppearance.getOutlineColor0();
+ } else {
+ return this.theme.getBundleOutlineColor0();
+ }
+ },
+ getOutlineColor1 : function() {
+ if (this.outlineColor1 != null) {
+ return this.outlineColor1;
+ } else if (this.parentAppearance != null) {
+ return parentAppearance.getOutlineColor1();
+ } else {
+ return this.theme.getBundleOutlineColor1();
+ }
+ },
+ getOutlineColor2 : function() {
+ if (this.outlineColor2 != null) {
+ return this.outlineColor2;
+ } else if (this.parentAppearance != null) {
+ return parentAppearance.getOutlineColor2();
+ } else {
+ return this.theme.getBundleOutlineColor2();
+ }
+ },
+ getBackgroundContrastColor : function() {
+ if (this.backgroundContrastColor != null) {
+ return this.backgroundContrastColor;
+ } else if (this.parentAppearance != null) {
+ return parentAppearance.getBackgroundContrastColor();
+ } else {
+ return this.theme.getBundleBackgroundContrastColor();
+ }
+ },
+ setBackgroundColor : function(state) {
+ this.backgroundColor = null;
+ if(state == "inactive") {
+ this.backgroundColor = this.theme.getBundleInactiveBackgroundColor();
+ } else {
+ this.backgroundColor = this.getBackgroundColor();
+ }
+ },
+ setBackgroundContrastColor : function(backgroundContrastColor) {
+ this.backgroundContrastColor = backgroundContrastColor;
+ },
+
+ useLinearShading : function() {
+ return this.theme.shouldUseLinearShading();
+
+ },
+ greyOutInactiveBundles : function() {
+ return this.theme.shouldGreyOutInactiveBundles();
+ },
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/Theme.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/Theme.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/Theme.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/configuration/Theme.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,79 @@
+/**
+ * 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.configuration.Theme");
+
+/*
+ * Still TODO: Read in the configuration from a flat file on the server side
+ * Read in the configuration from a cookie
+ * Provide a GUI for setting the theme aspects
+ * Provide pre-canned themes for users to choose from
+ */
+dojo.declare("goat.configuration.Theme", [], {
+
+ // object properties
+ greyOutInactiveBundles : null,
+ useLinearShading : null,
+ showState : null,
+ showVersion : null,
+ bundleBackgroundColor: "#ffff80",
+ bundleInactiveBackgroundColor : "#808080",
+ bundleBackgroundContrastColor: "#ffffff",
+ bundleOutlineColor0: "#808080",
+ bundleOutlineColor1: "#BA98E2",
+ bundleOutlineColor2: "#682DAE",
+ serviceBackgroundColor: "#FFFF33",
+
+ constructor : function() {
+ this.greyOutInactiveBundles = true;
+ this.useLinearShading = true;
+ this.showState = true;
+ this.showVersion = true;
+ },
+ shouldGreyOutInactiveBundles: function() {
+ return this.greyOutInactiveBundles;
+ },
+ shouldUseLinearShading: function() {
+ return this.useLinearShading;
+ },
+ getBundleBackgroundColor: function() {
+ return this.bundleBackgroundColor;
+ },
+ getBundleInactiveBackgroundColor: function() {
+ return this.bundleInactiveBackgroundColor;
+ },
+ getBundleBackgroundContrastColor: function() {
+ return this.bundleBackgroundContrastColor;
+ },
+ getServiceBackgroundColor: function() {
+ return this.serviceBackgroundColor;
+ },
+ getBundleOutlineColor0: function() {
+ return this.bundleOutlineColor0;
+ },
+ getBundleOutlineColor1: function() {
+ return this.bundleOutlineColor1;
+ },
+ getBundleOutlineColor2: function() {
+ return this.bundleOutlineColor2;
+ },
+ getTriangleSize: function() {
+ return 20;
+ }
+
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentColorElement.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentColorElement.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentColorElement.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentColorElement.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,70 @@
+/**
+ * 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.ComponentColorElement");
+
+dojo.require("goat.configuration.Theme");
+dojo.require("goat.configuration.ComponentAppearance");
+
+dojo
+ .declare("goat.elements.ComponentColorElement",
+ [ goat.elements.ElementBase ], {
+
+ value : null,
+ componentAppearance: null,
+
+ constructor : function(component, componentAppearance, /* String */type, /* String */
+ value) {
+ this.component = component;
+ this.componentAppearance = componentAppearance;
+ this.value = value;
+ this.type = type;
+ this.hint = "none";
+ console.log("on construction is " + this.value)
+ },
+ getWidth : function() {
+ return 0;
+ },
+ getHeight : function() {
+ return 0;
+ },
+ render : function() {
+ // No special rendering action needed
+ },
+ apply : function() {
+ if (this.type == "component.property.State") {
+ if (this.componentAppearance.greyOutInactiveBundles()) {
+ if (this.value != "ACTIVE") {
+ this.componentAppearance
+ .setBackgroundColor("inactive");
+ } else {
+ this.componentAppearance
+ .setBackgroundColor("active");
+ }
+ }
+ }
+
+ },
+ update : function(value) {
+ this.value = value;
+ },
+ removeSelf : function() {
+ // no op, we only exist due to the color of the owning
+ // component..
+ }
+
+ });
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentContainer.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentContainer.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentContainer.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ComponentContainer.js Sat Oct 30 15:42:36 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;
+ },
+ removeSelf: function(){
+
+ }
+
+ });
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementBase.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementBase.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementBase.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementBase.js Sat Oct 30 15:42:36 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
+dojo.provide("goat.elements.ElementBase");
+
+dojo.require("goat.configuration.Theme");
+dojo.require("goat.configuration.ComponentAppearance");
+
+dojo.declare("goat.elements.ElementBase", [], {
+
+ componentAppearance: null,
+ type: null,
+ component: null,
+ x: 0,
+ y: 0,
+ width: 0,
+ height: 0,
+ hint: "top",
+
+ constructor : function(component, componentAppearance) {
+ //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;
+ },
+ apply: function() {
+ //called before render to initialise shared characteristics (like colour)
+ },
+ render: function() {
+ //called to add this element to the screen at this.x, this.y
+ },
+ removeSelf: function() {
+ //called to remove this element from the screen
+ }
+
+
+ });
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementRegistry.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementRegistry.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementRegistry.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/ElementRegistry.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,66 @@
+/**
+ * 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.TwistieSection");
+dojo.require("goat.elements.ComponentColorElement");
+
+dojo.require("goat.configuration.ComponentAppearance");
+
+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, /*goat.configuration.ComponentAppearance*/ componentAppearance, /*String*/type, /*Object*/value){
+
+ // 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"){
+ 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);
+ }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.TwistieSection(component, type, value);
+ }
+ //else.. unknown property.. ignore it.
+}
+
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/RelationshipElement.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/RelationshipElement.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/RelationshipElement.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/RelationshipElement.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,201 @@
+/**
+ * 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.elements.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
+dojo.declare("goat.elements.RelationshipElement", [], {
+
+ //relationship properties.
+ fromComponent: null,
+ toComponent: null,
+ name: null,
+ type: null,
+
+ //object properties
+ surface: null,
+ visible: null,
+
+ //gfx objects
+ line: null,
+
+ // helper elements
+ decorators: null,
+
+ //internals
+ stroke: null,
+ pulseColor: "#682DAE",
+
+ //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 need to be replaced with a call to a configuration/theme
+ this.stroke = '#6D7B8D';
+
+ this.updateVisibility();
+
+ 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));
+
+ // 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));
+
+ 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(){
+
+ // Visible will be 'true' only if both componenets are not hidden (ie visible)
+ this.visible = (!this.fromComponent.hidden) && (!this.toComponent.hidden);
+
+ if(!this.visible){
+ if(this.line!=null){
+ //No need to hide a line that doesn't exist.
+ this.line.setShape({x1: -1000, y1: -1000, x2: -1000, y2: -1000});
+
+ //console.log("Hiding decorators..");
+ dojo.forEach(this.decorators, function(decorator){
+ decorator.makeInvisible();
+ },this);
+
+ }
+ }else{
+ this.updateLine();
+ }
+},
+updateLine: function(){
+
+ if(this.visible){
+ 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);
+ var toy = this.toComponent.y + (this.toComponent.height / 2);
+
+ if(this.line==null){
+ this.line = this.surface.createLine({x1: fromx, y1: fromy, x2: tox, y2: toy})
+ .setStroke(this.stroke);
+ }else{
+ this.line.setShape({x1: fromx, y1: fromy, x2: tox, y2: toy});
+ }
+
+ if (this.decorators != null) {
+ dojo.forEach(this.decorators, function(decorator){
+ decorator.lineUpdated(this.line);
+ },this);
+ }
+
+ // Our line should be underneath any decorations
+ this.line.moveToBack();
+ }
+
+},
+removeSelf: function(){
+ if(!this.removed){
+ this.removed = true;
+
+ if(this.line!=null) {
+ this.surface.remove(this.line);
+ }
+
+ dojo.forEach(this.decorators, function(decorator){
+ decorator.removeSelf();
+ });
+ this.decorators = new Array();
+
+ //console.log("Removing line subscriptions to components.");
+ dojo.forEach(this.subs, function(sub){
+ dojo.unsubscribe(sub);
+ });
+
+ this.subs = new Array();
+
+ if(this.fromComponent.id != this.toComponent.id) {
+ dojo.publish("goat.relationship.remove."+this.fromComponent.id,[this]);
+ dojo.publish("goat.relationship.remove."+this.toComponent.id,[this]);
+ } else {
+ 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");
+ }
+},
+getKey: function(){
+ var key = ""+this.fromComponent.id+"!"+this.toComponent.id+"!"+this.type+"!"+this.name;
+},
+onComponentMove: function(component){
+ this.updateLine();
+},
+onComponentResize: function(component){
+ this.updateLine();
+},
+onComponentHidden: function(component){
+ this.updateVisibility();
+},
+onComponentClick: function(component){
+
+ if(this.line!=null) {
+ dojox.gfx.fx.animateStroke({
+ shape: this.line,
+ duration: 500,
+ //color: {start: "#FF3030", end: this.stroke},
+ color: {start: this.pulseColor, end: this.stroke},
+ width: {start: 3, end: 2},
+ join: {values: ["miter", "bevel", "round"]}
+ }).play();
+ }
+}
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TextComponentProperty.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TextComponentProperty.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TextComponentProperty.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TextComponentProperty.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,70 @@
+/**
+ * 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.TextComponentProperty");
+
+dojo.declare("goat.elements.TextComponentProperty", goat.elements.ElementBase, {
+
+ value: null,
+ text: null,
+
+ constructor : function(component, /*String*/ type, /*String*/ value) {
+ //console.log("Adding "+type+" "+value);
+ //console.log(component);
+
+ this.component=component;
+ this.type=type;
+ this.value=value;
+ this.hint="row";
+ },
+ getWidth : function(){
+ var calcWidth=150;
+ if(this.value.length > 18){
+ var extra = this.value.length - 18;
+ extra = extra * 8; //rough estimate of 'per char extra needed over 150px once past 18chars' ;-)
+ return calcWidth + extra;
+ }
+ return calcWidth;
+ },
+ getHeight : function(){
+ return 14;
+ },
+ render : function(){
+ if(this.text!=null){
+ this.component.group.remove(this.text);
+ }
+ //console.log("Creating text node");
+ //console.log(this);
+
+ //text renders with 0,0 being the BOTTOM LEFT of the text object, we want to beleive all our objects have it as TOP LEFT
+ //so we add 12 to the ypos, 12 being the point height of our font.
+ this.text = this.component.group.createText({x: this.x, y: this.y+12, text: this.value, align: "start"})
+ .setFont({family: "times", size: "12pt"})
+ .setFill("#000000");
+ },
+ update: function(value){
+ this.value=value;
+ },
+ removeSelf: function(){
+ if(this.text!=null){
+ this.component.group.remove(this.text);
+ }
+ }
+
+ });
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TriangleDecorator.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TriangleDecorator.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TriangleDecorator.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TriangleDecorator.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,172 @@
+/**
+ * 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.elements.TriangleDecorator");
+dojo.require("dojox.gfx");
+dojo.require("dojox.gfx.Moveable");
+dojo.require("goat.Component");
+
+dojo.require("goat.configuration.Theme");
+
+// Triangle decorator
+// represents a triangle decoration for a line (usually representing a service).
+
+dojo.declare("goat.elements.TriangleDecorator", [], {
+
+ // object properties
+ surface : null,
+
+ // gfx objects
+ line : null,
+ triangle : null,
+ trianglegroup : null,
+
+ // internals
+ stroke : null,
+ theme : null,
+
+ // am I deleted?
+ removed : false,
+
+ // am I hidden?
+ hidden : false,
+
+ constructor : function(theme, surface) {
+ this.theme = theme;
+ this.surface = surface;
+ this.trianglegroup = this.surface.createGroup();
+ },
+ makeInvisible : function() {
+ //console.log("Hiding triangle..");
+ if(this.trianglegroup!=null) {
+ this.surface.remove(this.trianglegroup);
+ this.hidden=true;
+ }
+ },
+ setStroke : function(newStroke) {
+ this.stroke = newStroke;
+ },
+ lineUpdated : function(line) {
+ //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.hidden) {
+ //console.log("Unhiding triangle..");
+ this.hidden=false;
+ this.surface.add(this.trianglegroup);
+ }
+
+ if (line != null) {
+ var shape = line.getShape();
+ var fromx = shape.x1;
+ var fromy = shape.y1;
+ var tox = shape.x2;
+ var toy = shape.y2;
+
+ //avoid processing self-referential relationships
+ //not ideal, but serves the purpose until it's done differently.
+ if(fromx!=tox && fromy!=toy) {
+
+ // A somewhat awkwardly named method ...
+ var triangleSize = this.theme.getTriangleSize();
+ var deltax = tox - fromx;
+ var deltay = toy - fromy;
+ // Do a square root to work out the line length
+ // Will this hurt us on performance? An approximation would do
+ // if so ...
+ var lineLength = Math.sqrt(deltax * deltax + deltay * deltay);
+ // Assume the triangles are equilateral
+ var divider = lineLength / triangleSize;
+ // The triangle starts in the middle of the line
+ var tx1 = (fromx + tox) / 2;
+ var ty1 = (fromy + toy) / 2;
+ var tx2 = tx1 + deltax / divider + deltay / divider;
+ var ty2 = ty1 + deltay / divider - deltax / divider;
+ var tx3 = tx1 + deltax / divider - deltay / divider;
+ var ty3 = ty1 + deltay / divider + deltax / divider;
+
+ if (this.triangle == null) {
+ this.triangle = this.trianglegroup.createPolyline( [ {
+ x : tx1,
+ y : ty1
+ }, {
+ x : tx2,
+ y : ty2
+ }, {
+ x : tx3,
+ y : ty3
+ }, {
+ x : tx1,
+ y : ty1
+ } ]);
+ this.triangle.setStroke(this.stroke);
+
+ } else {
+ this.triangle.setShape( [ {
+ x : tx1,
+ y : ty1
+ }, {
+ x : tx2,
+ y : ty2
+ }, {
+ x : tx3,
+ y : ty3
+ }, {
+ x : tx1,
+ y : ty1
+ } ]);
+ }
+
+ if (this.theme.shouldUseLinearShading()) {
+ this.triangle.setFill( {
+ type : "linear",
+ x1 : tx1,
+ y1 : ty1,
+ x2 : tx2,
+ y2 : ty2,
+ colors : [ {
+ offset : 0,
+ color : this.theme.getServiceBackgroundColor()
+ }, {
+ offset : 1,
+ color : "white"
+ } ]
+ });
+ } else {
+ this.triangle.setFill(this.theme
+ .getServiceBackgroundColor());
+
+ }
+ }
+
+ }
+ },
+ removeSelf : function() {
+ if (!this.removed) {
+ this.removed = true;
+ if(this.triangle!=null) {
+ this.surface.remove(this.trianglegroup);
+ this.trianglegroup=null;
+ // console.log("Line from "+this.fromComponent.id+" to
+ // "+this.toComponent.id+" being marked as deleted");
+ }
+ }
+ }
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TwistieSection.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TwistieSection.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TwistieSection.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/elements/TwistieSection.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,223 @@
+/**
+ * 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 relationships to display - with dups removed.
+ this.items = new Array();
+ this.itemTexts = new Array();
+
+ this.name = this.type.substring("relationship.aggregation.".length, this.type.length);
+
+ 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"));
+
+ 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(){
+ this.component.group.remove(this.twistieGroup);
+ if(this.built) {
+ this.twistieHandleGroup.remove(this.twistieHandle);
+ this.twistieGroup.remove(this.twistieText);
+ }
+
+ //Create here because the component has reset this section's x, y cordinates.
+ this.createTwistie();
+ this.createText();
+
+ // This may not be the section that has asked for a component refresh. If is is not and it is open
+ // we need to redraw as the section may have moved as a result of something else above it
+ // being closed. If this IS the the section that requested the resize it has been resized in resizeOnOpen
+ // or resizeOnClose and the items need to be removed or added here.
+ this.removeItemsFromDisplay();
+ if(this.isOpen) {
+ this.addItemsToDisplay();
+ }
+ this.component.group.add(this.twistieGroup);
+ },
+ update: function(value){
+ },
+ removeSelf: 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.resizeOnOpen();
+ 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.resizeOnOpen();
+ this.component.refresh();
+ }
+ },
+ addItemsToDisplay: function(){
+ var pyt = this.y + 10;
+ var pxt = this.x + 17;
+ for(idx=0; idx<this.items.length; idx++){
+ pyt = pyt + 10;
+ this.itemTexts[idx] = this.twistieGroup.createText({x: pxt, y: pyt, text: this.items[idx], align: "start"})
+ .setFont({family: "times", size: "8pt"})
+ .setFill("#000000");
+ }
+ },
+ resizeOnOpen: function() {
+ var maxLengthSeen = 0;
+ var extraHeight = 12;
+ if(this.items!=null){
+ extraHeight = extraHeight + (this.items.length * 10);
+ var idx=0;
+
+ for(idx=0; idx<this.items.length; idx++){
+ 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;
+ },
+ resizeOnClose: function() {
+ this.height = 12;
+ this.width = 150;
+ },
+
+ removeItemsFromDisplay: function(){
+ if(this.itemTexts!=null){
+ for (var k in this.itemTexts) {
+ this.twistieGroup.remove(this.itemTexts[k]);
+ }
+ }
+ },
+ twistieHandler: function() {
+ this.isOpen=!this.isOpen;
+
+ if(this.isOpen){
+ this.resizeOnOpen();
+ }else{
+ this.resizeOnClose();
+ }
+
+ this.component.refresh();
+ },
+ createText: function(){
+ var textOffset = this.y + 10;
+ var x = this.x + 17;
+ this.twistieText = this.twistieGroup.createText({x: x, y: textOffset, text: this.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}]).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;
+ }
+
+
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/AspectBase.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/AspectBase.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/AspectBase.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/AspectBase.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,28 @@
+/**
+ * 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.relationshipaspects.AspectBase");
+
+dojo.declare("goat.relationshipaspects.AspectBase", [], {
+
+constructor : function() {
+
+}
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Parameterized.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Parameterized.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Parameterized.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Parameterized.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,28 @@
+/**
+ * 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.relationshipaspects.Parameterized");
+
+dojo.declare("goat.relationshipaspects.Parameterized", goat.relationshipaspects.AspectBase, {
+
+constructor : function() {
+
+}
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Versioned.js
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Versioned.js?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Versioned.js (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/relationshipaspects/Versioned.js Sat Oct 30 15:42:36 2010
@@ -0,0 +1,28 @@
+/**
+ * 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.relationshipaspects.Versioned");
+
+dojo.declare("goat.relationshipaspects.Versioned", goat.relationshipaspects.AspectBase, {
+
+constructor : function() {
+
+}
+
+});
Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/index.html
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/index.html?rev=1029102&view=auto
==============================================================================
--- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/index.html (added)
+++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/index.html Sat Oct 30 15:42:36 2010
@@ -0,0 +1,147 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ 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.
+-->
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+
+<style type="text/css">
+@import "../dojo/resources/dojo.css";
+@import "../dijit/themes/tundra/tundra.css";
+@import "../dojox/grid/resources/Grid.css";
+@import "../dojox/grid/resources/tundraGrid.css";
+.grid {
+ width: 70em;
+ height: 40em;
+}
+body, html {
+ width:100%;
+ height:100%;
+}
+#borderContainer {
+ width:100%;
+ height:100%;
+}
+
+</style>
+
+<title>Apache Aries GOAT</title>
+
+<!-- DWR Includes and Setup -->
+<script src='../dwr/engine.js'></script>
+
+<script type='text/javascript' src='../dwr/util.js'> </script>
+<script type='text/javascript' src='../dwr/interface/ServerSideClass.js'></script>
+
+<!-- enable active reverse ajax.. -->
+<script type='text/javascript'>
+ dwr.engine.setActiveReverseAjax(true);
+</script>
+
+<script type="text/javascript" src="../dojo/dojo.js"
+ djConfig="debugAtAllCosts:true, isDebug:true, parseOnLoad: true"></script>
+
+<script type='text/javascript'>
+
+ dojo.registerModulePath("goat", "/org.apache.aries.samples.dgoat.web/web/goat");
+
+ dojo.require("dojox.gfx");
+ dojo.require("dojox.gfx.move");
+
+
+ dojo.require("dojo.parser");
+ dojo.require("dojo.cookie");
+ dojo.require("dojo.data.ItemFileWriteStore");
+
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.Select");
+ dojo.require("dijit.form.TextBox");
+ dojo.require("dijit.Dialog");
+ dojo.require("dijit.layout.BorderContainer");
+ dojo.require("dijit.layout.ContentPane");
+ dojo.require("dijit.layout.AccordionContainer");
+ dojo.require("dijit.layout.AccordionPane");
+
+
+
+ dojo.require("goat.Component");
+ dojo.require("goat.Relationship");
+ dojo.require("goat.ProviderSelector");
+ dojo.require("goat.LayoutManager");
+ dojo.require("goat.ComponentStatusGrid");
+ dojo.require("goat.SimpleInitialLayout");
+ dojo.require("goat.DwrLoadingDialog");
+
+ dojo.require("goat.configuration.Theme");
+
+ //provides the basic layout when 1st loading up bundles.
+ var initialLayout = null;
+ //tracks the current provider for the app.
+ var providerSelector = null;
+
+ //the global component array, indexed by component id.
+ var components = new Array();
+
+ //the global relationship array, indexed by relationship key.
+ var relationships = new Array();
+
+ var theme = null;
+
+ //various gfx decls.
+ var container = null, surface = null, surface_size = null;
+
+ function setup() {
+ container = dojo.byId("gfx_holder");
+ surface = dojox.gfx.createSurface(container, 1000, 1000);
+ surface_size = {
+ width : 1000,
+ height : 1000
+ };
+ //the global theme - in time, we may wish to make its initialization more sophisticated
+ theme = new goat.configuration.Theme();
+
+ initialLayout = new goat.SimpleInitialLayout(1000,1000);
+ var loadingDialog = new goat.DwrLoadingDialog();
+ var componentStatusGrid = new goat.ComponentStatusGrid("stateTableID");
+ providerSelector = new goat.ProviderSelector("providerSelectorID");
+ var loadSave = new goat.LayoutManager("loadSaveLayoutID");
+ }
+
+ dojo.addOnLoad(setup);
+</script>
+
+<script type='text/javascript' src='../web/goat/ServerSideInterface.js'> </script>
+
+</head>
+<body class="tundra">
+<div dojoType="dijit.layout.BorderContainer" design="sidebar" gutters="true"
+ style="width: 100%; height: 100%;">
+ <div dojoType="dijit.layout.ContentPane" region="leading" splitter="true" style="width: 300px;">
+ <div style="width: 300px;" id="stateTableID"></div>
+ </div>
+
+ <div dojoType="dijit.layout.ContentPane" region="top" style="height: 20px;">
+ <span id="providerSelectorID"></span><span id="loadSaveLayoutID"></span>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" region="center" style="padding: 10px;">
+ <div id="gfx_holder" style="width: 100%; height: 100%;"></div>
+ </div>
+ </div>
+
+</body>
+</html>