You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/07/05 02:06:56 UTC
svn commit: r419134 - in /incubator/xap/trunk/src/xap/bridges/dojo:
DojoFloatingPaneBridge.js DojoLayoutContainerBridge.js
DojoLayoutPaneBridge.js DojoSplitPaneBridge.js DojoWidgetBridge.js
Author: mturyn
Date: Tue Jul 4 19:06:55 2006
New Revision: 419134
URL: http://svn.apache.org/viewvc?rev=419134&view=rev
Log:
The generic widget bridge, button bridge, and floating pane bridges are furthest along.
Added:
incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutContainerBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutPaneBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/DojoSplitPaneBridge.js
Modified:
incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
Added: incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js?rev=419134&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js Tue Jul 4 19:06:55 2006
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ */
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class that controls a dojo FloatingPane peer.
+ */
+
+/**
+ * Creates a DojoFloatingPaneBridge.
+ *
+ *
+ * @class DojoFloatingPaneBridge is the bridge between an XML element
+ * representing a button and the Dojo FloatingPane class.
+ *
+ * @author jmargarisz
+ * @author mturyn
+ */
+
+// Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+// Xap.provides("xap.bridges.dojo.DojoFloatingPaneBridge");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit button peer.
+ */
+
+DojoFloatingPaneBridge= function() {
+ DojoWidgetBridge.call(this);
+}
+
+DojoFloatingPaneBridge.prototype = new DojoWidgetBridge;
+
+
+DojoFloatingPaneBridge.prototype.constructor=DojoFloatingPaneBridge ;
+
+DojoFloatingPaneBridge.s_log = LogFactory.getLog( "DojoFloatingPaneBridge" );
+
+DojoFloatingPaneBridge.prototype.toString = function() {
+ return "DojoFloatingPaneBridge";
+}
+
+
+
+DojoFloatingPaneBridge.prototype.getPeerString = function(){
+ return "FloatingPane" ;
+}
+
+
+
+
+/**
+ * The callback for the selection listener on DojoFloatingPane.
+ * When this is called we fire an "onCommand" event.
+ */
+DojoFloatingPaneBridge.prototype._onSelectEvent = function( event ) {
+ this.fireEvent("onCommand");
+}
+
+
+/**
+ * This method is called whenever an attribute
+ * on the XML element that maps to this bridge class
+ * is changed.
+ * <ul>
+ * <li>text - the HTML text of the label</li>
+ * </ul>
+ *
+ * Attributes not handled here are are passed to the
+ * superclass attributeSet method.
+ */
+DojoFloatingPaneBridge.prototype.attributeSet = function( event ) {
+ var name = event.getName();
+ var value = event.getNewValue();
+ var peer = this.getPeer();
+
+ if (name=="layoutAlign"){
+ peer.layoutAlign = value ;
+ }
+ else if (name=="title"){
+ peer.title = value ;
+ } else {
+ DojoWidgetBridge.prototype.attributeSet.call( this, event );
+ }
+ peer.onResized() ;
+}
+
+
Added: incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutContainerBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutContainerBridge.js?rev=419134&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutContainerBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutContainerBridge.js Tue Jul 4 19:06:55 2006
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ */
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class that controls a dojo LayoutContainer peer.
+ */
+
+/**
+ * Creates a DojoLayoutContainerBridge.
+ *
+ *
+ * @class DojoLayoutContainerBridge is the bridge between an XML element
+ * representing a button and the Dojo LayoutContainer class.
+ *
+ * @author jmargarisz
+ * @author mturyn
+ */
+
+// Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+// Xap.provides("xap.bridges.dojo.DojoLayoutContainerBridge");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit button peer.
+ */
+
+DojoLayoutContainerBridge= function() {
+ DojoWidgetBridge.call(this);
+}
+
+DojoLayoutContainerBridge.prototype = new DojoWidgetBridge;
+
+
+DojoLayoutContainerBridge.prototype.constructor=DojoLayoutContainerBridge ;
+
+DojoLayoutContainerBridge.s_log = LogFactory.getLog( "DojoLayoutContainerBridge" );
+
+DojoLayoutContainerBridge.prototype.toString = function() {
+ return "DojoLayoutContainerBridge";
+}
+
+
+
+DojoLayoutContainerBridge.prototype.getPeerString = function(){
+ return "LayoutContainer" ;
+}
+
+/**
+ * This is a container, not a widget, so it doesn't use createWidget
+ * Need to give the new layout an empsty array of children.
+ */
+DojoLayoutContainerBridge.prototype.createPeer = function() {
+ var parent = this.getElement().getParent();
+ var handler = this.getUiContentHandler().getHandlerForElement( parent );
+ var parentPeer = handler.getPeer();
+
+ // Hmmm...is there a better, generic, way
+ // of describing an element that contains
+ // a Dojo layout?
+ if ( parentPeer.nodeName=="DIV"
+ || parentPeer.nodeName=="BODY"
+ || parentPeer.nodeName=="TD"
+ ) {
+
+
+ var peer = new dojo.html.layout(parentPeer, [], "none" ) ;
+
+ this.setPeer( peer );
+ //peer.addSelectionListener(new AjxListener(this, this._onSelectEvent));
+ } else {
+ DojoWidgetBridge.s_log.error("Bogus parent peer:" + parentPeer );
+ }
+}
+
+
+/**
+ * The callback for the selection listener on DojoLayoutContainer.
+ * When this is called we fire an "onCommand" event.
+ */
+DojoLayoutContainerBridge.prototype._onSelectEvent = function( event ) {
+ this.fireEvent("onCommand");
+}
+
+
+/**
+ * This method is called whenever an attribute
+ * on the XML element that maps to this bridge class
+ * is changed.
+ * <ul>
+ * <li>text - the HTML text of the label</li>
+ * </ul>
+ *
+ * Attributes not handled here are are passed to the
+ * superclass attributeSet method.
+ */
+DojoLayoutContainerBridge.prototype.attributeSet = function( event ) {
+ var name = event.getName();
+ var value = event.getNewValue();
+ var peer = this.getPeer();
+
+ if (name=="layoutPriority"){
+ peer.layoutPriority = value ;
+ }
+ else if (name=="layoutAlign"){
+ peer.layoutAlign = value ;
+ }
+ else {
+ DojoWidgetBridge.prototype.attributeSet.call( this, event );
+ }
+ peer.onResized() ;
+}
+
+
Added: incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutPaneBridge.js?rev=419134&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutPaneBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoLayoutPaneBridge.js Tue Jul 4 19:06:55 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ */
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class that controls a dojo LayoutPane peer.
+ */
+
+/**
+ * Creates a DojoLayoutPaneBridge.
+ *
+ *
+ * @class DojoLayoutPaneBridge is the bridge between an XML element
+ * representing a button and the Dojo LayoutPane class.
+ *
+ * @author jmargarisz
+ * @author mturyn
+ */
+
+// Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+// Xap.provides("xap.bridges.dojo.DojoLayoutPaneBridge");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit button peer.
+ */
+
+DojoLayoutPaneBridge= function() {
+ DojoWidgetBridge.call(this);
+}
+
+DojoLayoutPaneBridge.prototype = new DojoWidgetBridge;
+
+
+DojoLayoutPaneBridge.prototype.constructor=DojoLayoutPaneBridge ;
+
+DojoLayoutPaneBridge.s_log = LogFactory.getLog( "DojoLayoutPaneBridge" );
+
+DojoLayoutPaneBridge.prototype.toString = function() {
+ return "DojoLayoutPaneBridge";
+}
+
+
+
+DojoLayoutPaneBridge.prototype.getPeerString = function(){
+ return "LayoutPane" ;
+}
+
+
+
+
+/**
+ * The callback for the selection listener on DojoLayoutPane.
+ * When this is called we fire an "onCommand" event.
+ */
+DojoLayoutPaneBridge.prototype._onSelectEvent = function( event ) {
+ this.fireEvent("onCommand");
+}
+
+
+/**
+ * This method is called whenever an attribute
+ * on the XML element that maps to this bridge class
+ * is changed.
+ * <ul>
+ * <li>text - the HTML text of the label</li>
+ * </ul>
+ *
+ * Attributes not handled here are are passed to the
+ * superclass attributeSet method.
+ */
+DojoLayoutPaneBridge.prototype.attributeSet = function( event ) {
+ var name = event.getName();
+ var value = event.getNewValue();
+ var peer = this.getPeer();
+
+ if (name=="layoutAlign"){
+ peer.layoutAlign = value ;
+ }
+ else{
+ DojoWidgetBridge.prototype.attributeSet.call( this, event );
+ }
+ peer.onResized() ;
+}
+
+
Added: incubator/xap/trunk/src/xap/bridges/dojo/DojoSplitPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoSplitPaneBridge.js?rev=419134&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoSplitPaneBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoSplitPaneBridge.js Tue Jul 4 19:06:55 2006
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ */
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class that controls a dojo SplitPane peer.
+ */
+
+/**
+ * Creates a DojoSplitPaneBridge.
+ *
+ *
+ * @class DojoSplitPaneBridge is the bridge between an XML element
+ * representing a button and the Dojo SplitPane class.
+ *
+ * @author jmargaris
+ * @author mturyn
+ */
+
+ //Xap.require("xap.bridges.dojo.DojoPaneBridge");
+// Xap.require("dojo.widget.SplitPane");
+
+/**
+ * @private
+ * A list of properties to be held by any
+ * DojoSplitPane instances and handled directly
+ * by this bridge, not a superclass.
+**/
+DojoSplitPaneBridge._propertyMap = {"orientation":true, "sizerWidth":true, "activeSizing":true,
+ "sizeMin":true, "sizeShare":true} ;
+
+/**
+ * isManagedProperty
+ * @param propertyName Does a DojoSplitPaneBridge handle this property?
+ * @return boolean
+**/
+DojoSplitPaneBridge.hasManagedPeerProperty = function(propertyName){
+ return (DojoSplitPaneBridge._propertyMap[propertyName]!= null) ;
+}
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit button peer.
+ */
+
+DojoSplitPaneBridge= function() {
+ DojoPaneBridge.call(this);
+}
+
+DojoSplitPaneBridge.prototype = new DojoPaneBridge;
+
+
+DojoSplitPaneBridge.prototype.constructor=DojoSplitPaneBridge ;
+
+DojoSplitPaneBridge.s_log = LogFactory.getLog( "DojoSplitPaneBridge" );
+
+DojoSplitPaneBridge.prototype.toString = function() {
+ return "DojoSplitPaneBridge";
+}
+
+
+
+DojoSplitPaneBridge.prototype.getPeerString = function(){
+ return "SplitPane" ;
+}
+
+
+
+
+
+/**
+ * This method is called whenever an attribute
+ * on the XML element that maps to this bridge class
+ * is changed.
+ * <ul>
+ * <li>text - the HTML text of the label</li>
+ * </ul>
+ *
+ * Attributes not handled here are are passed to the
+ * superclass attributeSet method.
+ */
+DojoSplitPaneBridge.prototype.attributeSet = function( event ) {
+ var name = event.getName();
+ var value = event.getNewValue();
+ var peer = this.getPeer();
+
+ if ( DojoSplitPaneBridge.hasManagedPeerProperty(name) ){
+ //Simple
+ peer[name] = value ;
+ }
+ else{
+ DojoPaneBridge.prototype.attributeSet.call( this, event );
+ }
+ peer.onResized() ;
+}
+
+
+
+
+
Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js?rev=419134&r1=419133&r2=419134&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Tue Jul 4 19:06:55 2006
@@ -39,6 +39,11 @@
*/
DojoWidgetBridge = function() {
AbstractTagImpl.call( this );
+ // handle a object that we might pass in directly
+ // to the dojo object peer:
+ if( arguments.length > 0 && (typeof arguments[0] == "object") ) {
+ this._passedInDojoProperties = arguments[0] ;
+ }
}
DojoWidgetBridge.prototype = new AbstractTagImpl;
@@ -79,6 +84,14 @@
var handler = this.getUiContentHandler().getHandlerForElement( parent );
var parentPeer = handler.getPeer();
+ // This is necessary if a Dojo widget is the parentPeer:
+ // This is probably a kludge, but I don't want to
+ // muck around with handler.getPeer() at the moment:
+ if( parentPeer.containerNode ){
+ parentPeer = parentPeer.containerNode ;
+ }
+
+
// Hmmm...is there a better, generic, way
// of describing an element that contains
// a Dojo widget?
@@ -88,9 +101,38 @@
) {
var tmp = document.createElement("DIV") ;
parentPeer.appendChild(tmp) ;
- var widgetId = this.getElement().getAttribute("id") ;
- var dojoType = this.getPeerString() ;
- var peer = dojo.widget.createWidget(dojoType, {widgetId:widgetId,position:"absolute"},tmp);
+
+ tmp.parent = parentPeer ;
+
+ // These properties of the map might be overwritten by a passed-in map:
+ // (by default, widget i.d. === xap i.d.)
+ // This method should be spun off into an overridden
+ // getPropertyMap that can be widget-specific:
+ var propertyMap = {widgetId:this.getElement().getAttribute("id"),
+ position:"absolute", title:"TO DO: working 'setTitle()' method"
+ } ;
+ // Allow us to put in any properties that might be in some dojo
+ // original:
+ if(this._passedInDojoProperties){
+ for(var prop in this._passedInDojoProperties){
+ propertyMap[prop] = this._passedInDojoProperties[prop] ;
+ }
+ }
+ // Forbid changing the dojoType if we've got one:
+ var dojoType = null ;
+ if ( this.getPeerString ){
+ dojoType = this.getPeerString() ;
+ } else {
+ dojoType = propertyMap.dojoType ;
+ }
+ delete propertyMap.dojoType
+
+ if (dojoType == null ){
+ // Make this a XapException once we're stable:
+ throw new Exception("No dojo type specified by class or passed-in map.") ;
+ }
+
+ var peer = dojo.widget.createWidget(dojoType,propertyMap,tmp);
this.setPeer( peer );
//peer.addSelectionListener(new AjxListener(this, this._onSelectEvent));
@@ -138,7 +180,12 @@
var value = event.getNewValue();
var peer = this.getPeer();
var shouldResize=false ;
- if ( name=="x" ) {
+
+ if ( name=="debugName" ) {
+ peer.debugName = value ;
+ shouldResize = true ; ;
+ }
+ else if ( name=="x" ) {
// peer.setLocation( value, null );
peer.domNode.style.left = value ;
shouldResize = true ; ;