incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r523226 - in /incubator/xap/trunk: codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js samples/WebContent/examples/widgets/horizontalSplitPane.xal samples/WebContent/examples/widgets/verticalSplitPane.xal
Date Wed, 28 Mar 2007 08:21:25 GMT
Author: mturyn
Date: Wed Mar 28 01:21:24 2007
New Revision: 523226

URL: http://svn.apache.org/viewvc?view=rev&rev=523226
Log:
Added "splitPosition" attribute, a number in [0,100], which will be used to set the proportion
of the split pane occupied by the left (for horizontal split panes) or right (for vertical
split panes) pane.

Limitation: 
	1.) Will only work properly if the [ <left/> and <right/> | <top/> and
<bottom/>] children are declared in that order.
	2.) Doesn't work properly if one of the children is empty.

Updated examples to show use "splitPosition", added borders so that its effects could be seen.



Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js
    incubator/xap/trunk/samples/WebContent/examples/widgets/horizontalSplitPane.xal
    incubator/xap/trunk/samples/WebContent/examples/widgets/verticalSplitPane.xal

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js?view=diff&rev=523226&r1=523225&r2=523226
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/VerticalSplitPaneBridge.js Wed Mar 28
01:21:24 2007
@@ -69,15 +69,21 @@
  */ 
  
  
+xap.bridges.dojo.VerticalSplitPaneBridge.isFirstPanel = function(handler){
+
+	return ("left,top").indexOf(handler.getElement().nodeName) + 1 ;
+}
+
+ 
 /**
  * No new dynamic attributes
  */
 xap.bridges.dojo.VerticalSplitPaneBridge.prototype.getNewAllowedAttributes = function(){
-	return [];
+	return ["splitPosition"];
 }	
 
 xap.bridges.dojo.VerticalSplitPaneBridge.prototype.addChild = function(childHandler, index){
-	
+//xap.util.Utils.interrogate(childHandler.getElement(),true,20) ;	
 	var insertIndex = -1;
 	if (childHandler instanceof xap.bridges.dojo.SecondSplitChildBridge){
 		insertIndex = this.getPeer().children.length;
@@ -87,10 +93,84 @@
 		insertIndex = 0;
 		childHandler._splitPaneBridge = this;
 	}
-	if (insertIndex>-1 && childHandler.getPeer()){
+	if( insertIndex>-1 && childHandler.getPeer() ){
 		xap.bridges.dojo.DojoWidgetBridge.prototype.addChild.call(this,childHandler,insertIndex);
-	}
+		// Until initialised, wait until we're done initialising
+		// before we start adjusting:
+		if(this._initted){
+			this.adjustSplitter() ;
+		}
+	}	
+
+}
+
+
+xap.bridges.dojo.VerticalSplitPaneBridge.prototype.setSplitPositionAttribute = function(str){
+	this._splitPosition = dj_global.parseInt(str) ;
+	this.adjustSplitter() ;
+}
+
+xap.bridges.dojo.VerticalSplitPaneBridge.prototype.getSplitPositionFromElement = function(){
+	// Default for a two-panel split:
+		var result = 50 ;
+		var strPos = this.getElement().getAttribute("splitPosition") ;
+		if( strPos ){
+			result  = dj_global.parseInt(strPos) ;
+		}
+		return result ;
+}
+
+xap.bridges.dojo.VerticalSplitPaneBridge.prototype.init = function(e){
+
 	
+	this._initted = false ;
+	xap.bridges.dojo.VerticalSplitPaneBridge.superclass.init.call(this,e) ;
+	this._initted = true ;
+	this.getPeer().persist = false ;	
+	this.adjustSplitter() ;
 }
 
+xap.bridges.dojo.VerticalSplitPaneBridge.prototype.adjustSplitter = function(){
+
+	var peer = this.getPeer() ;
+	if( !peer ){
+		return ;
+	}
+	var children = peer.children ;
+	
+//	var uch = this.getUiContentHandler() ;
+	
+	this._splitPosition = this.getSplitPositionFromElement() ;	
+	for( var ii=0; ii<children.length; ++ii){
+		var childPeer = children[ii] ;	
+		// Default: all are equal:
+		childPeer.sizeShare = 50 ;
+// This would be better, except that we can't map this way
+// from peers to handlers:
+//		var childHandler = uch.getHandlerForPeer(childPeer) ;
+//		if( !childHandler ){
+//			// Not all peers' children have handlers...
+//			continue ;
+//		}	
+
+		if(!isNaN(this._splitPosition)){
+			var share = this._splitPosition ;
+			// This is a hack that only works
+			// if the children are in left,right
+			// or top,bottom order:
+			if( childPeer.dojoInsertionIndex == 0 ){
+			//if(xap.bridges.dojo.VerticalSplitPaneBridge.isFirstPanel(childHandler)){
+			//if( childPeer._isAFirstChildPeer ){
+				// This is a left or top child; all is 
+				// as we need it already:
+			} else {
+				// Only two panels, 100%=100
+				share = 100 - share ; 
+			}
+			childPeer.sizeShare = share ;
+			// alert("Share: "+share) ;			
+		}
+	}
+	this.getPeer()._layoutPanels() ;	
+}
 

Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/horizontalSplitPane.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/horizontalSplitPane.xal?view=diff&rev=523226&r1=523225&r2=523226
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/horizontalSplitPane.xal (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/horizontalSplitPane.xal Wed Mar
28 01:21:24 2007
@@ -31,32 +31,55 @@
 			<horizontalBoxPane>
 				<freePane width="500px" height="300px" backgroundColor="#F0F0F0"
 					id="testComponentFreePane">
-					<xal:horizontalSplitPane id="testComponent" width="300px" height="200px">
-						<xal:left id="left" onCreate="mco:attributeSetter.registerElement(this)">
-							<label text="foo"/>
-						</xal:left>
-						<xal:right id="right" onCreate="mco:attributeSetter.registerElement(this)">
-							<label text="bar"/>
-						</xal:right>
+					<xal:horizontalSplitPane splitPosition="30"
+						id="testComponent" width="300px" height="200px"
+						borderWidth="4px" borderColor="silver" borderStyle="outset"						
+					>
+
+						<xal:left id="left" 
+						
+						onCreate="mco:attributeSetter.registerElement(this)">
+							<label text="L123456789112345678902123456789" backgroundColor="white"/>
+						</xal:left>
+
+						<xal:right id="right" onCreate="mco:attributeSetter.registerElement(this)">
+							<label text="R123456789112345678902123456789" backgroundColor="rgb(240,240,255)"/>
+						</xal:right>
+
+
 					</xal:horizontalSplitPane>
 				</freePane>
 				<freePane width="500px" height="300px" backgroundColor="#CCCCCC"
 					id="testComponentFreePane2" onCreate="mco:attributeSetter.registerElement(this)">
-					<xal:horizontalSplitPane width="200px" height="100px">
-						<xal:top height="100px">
-							<label text="top" width="100px"/>
-						</xal:top>
-						<xal:bottom height="100px">
-							<label text="bottom" width="100px"/>
-						</xal:bottom>
+					<xal:horizontalSplitPane splitPosition="70" 
+						width="200px" height="100px"
+						borderWidth="4px" borderColor="black" borderStyle="solid"	
+					>
+
+						<xal:left height="100px" >
+							<label text="left" width="100px"/>
+						</xal:left>
+
+						<xal:right height="100px">
+							<label text="right" width="100px"/>
+						</xal:right>
+
+
 					</xal:horizontalSplitPane>
-					<xal:horizontalSplitPane x="200px" y="0px" width="200px" height="100px">
-						<xal:left width="100px">
-							<label text="left" width="100px"/>
-						</xal:left>
-						<xal:right width="100px">
-							<label text="right" width="100px"/>
-						</xal:right>
+					<xal:horizontalSplitPane  x="200px" y="0px" width="200px" height="100px"
+						borderWidth="4px" borderColor="blue" borderStyle="double"					
+					>
+
+						<xal:left width="100px"  >
+							<label text="left" width="100px"/>
+						</xal:left>
+
+
+						<xal:right width="100px"  >
+							<label text="right" width="100px"/>
+						</xal:right>
+
+
 					</xal:horizontalSplitPane>
 				</freePane>
 			</horizontalBoxPane>

Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/verticalSplitPane.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/verticalSplitPane.xal?view=diff&rev=523226&r1=523225&r2=523226
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/verticalSplitPane.xal (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/verticalSplitPane.xal Wed Mar
28 01:21:24 2007
@@ -31,7 +31,9 @@
 			<horizontalBoxPane>
 				<freePane width="500px" height="300px" backgroundColor="#F0F0F0"
 					id="testComponentFreePane">
-					<xal:verticalSplitPane id="testComponent" width="300px" height="200px">
+					<xal:verticalSplitPane splitPosition="80" id="testComponent" width="300px" height="200px"
+						borderWidth="4px" borderColor="silver" borderStyle="outset"					
+					>
 						<xal:top id="top" onCreate="mco:attributeSetter.registerElement(this)">
 							<label text="foo"/>
 						</xal:top>
@@ -42,7 +44,9 @@
 				</freePane>
 				<freePane width="500px" height="300px" backgroundColor="#CCCCCC"
 					id="testComponentFreePane2">
-					<xal:verticalSplitPane width="200px" height="100px">
+					<xal:verticalSplitPane  splitPosition="30" width="200px" height="100px"
+						borderWidth="4px" borderColor="black" borderStyle="solid"					
+					>
 						<xal:top height="100px">
 							<label text="top" width="100px"/>
 						</xal:top>
@@ -50,13 +54,15 @@
 							<label text="bottom" width="100px"/>
 						</xal:bottom>
 					</xal:verticalSplitPane>
-					<xal:verticalSplitPane x="200px" y="0px" width="200px" height="100px">
-						<xal:left width="100px">
+					<xal:verticalSplitPane x="200px" y="0px" width="200px" height="100px"
+						borderWidth="4px" borderColor="blue" borderStyle="inset"					
+					>
+						<xal:top width="100px">
 							<label text="left" width="100px"/>
-						</xal:left>
-						<xal:right width="100px">
+						</xal:top>
+						<xal:bottom width="100px">
 							<label text="right" width="100px"/>
-						</xal:right>
+						</xal:bottom>
 					</xal:verticalSplitPane>
 				</freePane>
 			</horizontalBoxPane>



Mime
View raw message