incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r489485 - in /incubator/xap/trunk: src/xap/taghandling/PluginRegistryImpl.js src/xap/taghandling/plugin.xml testsrc/xap/taghandling/_TestPluginRegistryImpl.js testsrc/xap/taghandling/plugin.xml
Date Thu, 21 Dec 2006 22:37:23 GMT
Author: jmargaris
Date: Thu Dec 21 14:37:22 2006
New Revision: 489485

URL: http://svn.apache.org/viewvc?view=rev&rev=489485
Log:
no need to duplicate mappings now, can have multiple
namespace entries space separated

Modified:
    incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml
    incubator/xap/trunk/testsrc/xap/taghandling/_TestPluginRegistryImpl.js
    incubator/xap/trunk/testsrc/xap/taghandling/plugin.xml

Modified: incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js?view=diff&rev=489485&r1=489484&r2=489485
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js Thu Dec 21 14:37:22 2006
@@ -181,60 +181,65 @@
 		if (documentName==null){
 			documentName = xap.xml.DocumentContainer.UI_DOCUMENT_NAME;
 		}
+		
+		//TODO if they don't have a namespace attribute at all should report an exception
 		var nameSpace = tagMappingRoot.getAttribute("namespace");
 		
-		//for each child of that tag in the block
-		for (var i = 0; i<tagMappingRoot.childNodes.length; i++){
-			var tagElement = tagMappingRoot.childNodes[i];
+		var nameSpaces = nameSpace.split(" ");
+		
+		for (var nameSpaceIndex = 0; nameSpaceIndex<nameSpaces.length; nameSpaceIndex++){
+			nameSpace = nameSpaces[nameSpaceIndex];
 			
-			var className = null;
-			var tagName = null;
+			if (!nameSpace && isMappedTag){
+				//if the namespace is blank and the tag is supposed to be mapped
+				//just continue, most likely there was extra whitespace that split
+				//turned into a blank string
+				continue;
+			}
 			
-			//v2 syntax:
-			//<mapping name="pieChart" class="piechart.PieChartBridge"/>
-			if (tagElement.getLocalName()=="mapping"){
-				tagName = tagElement.getAttribute("name");
+			//for each child of that tag in the block
+			for (var i = 0; i<tagMappingRoot.childNodes.length; i++){
+				var tagElement = tagMappingRoot.childNodes[i];
 				
-				if (tagName==null || tagName.length==0){
-					if (xap.util.LogFactory.s_loggingEnabled)
-						xap.taghandling.PluginRegistryImpl.s_log.error(
-							"Missing tag name (\"local name\") from tag element:\n"
-							+ tagElement
-							+"\n...; mapping will continue for other tag defs."
-												     ) ;
-					continue;
-				}
+				var className = null;
+				var tagName = null;
 				
-				if (isMappedTag){
-					className = tagElement.getAttribute("class");
-					if (className==null || className.length==0){
-						//TODO report exception
+				//v2 syntax:
+				//<mapping name="pieChart" class="piechart.PieChartBridge"/>
+				if (tagElement.getLocalName()=="mapping"){
+					tagName = tagElement.getAttribute("name");
+					
+					if (tagName==null || tagName.length==0){
+						if (xap.util.LogFactory.s_loggingEnabled)
+							xap.taghandling.PluginRegistryImpl.s_log.error(
+								"Missing tag name (\"local name\") from tag element:\n"
+								+ tagElement
+								+"\n...; mapping will continue for other tag defs."
+													     ) ;
 						continue;
 					}
-// Eliminate this in favour of just-in-time loading:
-//					try{
-//						Xap.require(className);						
-//					}
-//					catch(exception){
-//						if (this._session){
-//							this._session.handleException(exception);
-//						}
-//						//TODO if error here then what? keep the mapping anyway?
-//					}
+					
+					if (isMappedTag){
+						className = tagElement.getAttribute("class");
+						if (className==null || className.length==0){
+							//TODO report exception
+							continue;
+						}
+					}
+					//if we aren't supposed to be mapped to anything
+					//don't look for class
+					else{
+						className = xap.taghandling.PluginRegistryImpl.NO_MAPPED_CLASS
+					}
 				}
-				//if we aren't supposed to be mapped to anything
-				//don't look for class
 				else{
-					className = xap.taghandling.PluginRegistryImpl.NO_MAPPED_CLASS
+					//TODO report exception	
+					
 				}
-			}
-			else{
-				//TODO report exception	
 				
+				xap.taghandling.PluginRegistryImpl.s_log.debug("Add tag mapping:" + tagName + ":" + className);
+				this._addTagMapping(tagName,className,nameSpace,documentName,tagElement);
 			}
-			
-			xap.taghandling.PluginRegistryImpl.s_log.debug("Add tag mapping:" + tagName + ":" + className);
-			this._addTagMapping(tagName,className,nameSpace,documentName,tagElement);
 		}
 	}
 }

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?view=diff&rev=489485&r1=489484&r2=489485
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Thu Dec 21 14:37:22 2006
@@ -44,7 +44,7 @@
 	
 
 	<!-- default mappings -->
-	<tag-mappings namespace="http://openxal.org/ui" document="ui">
+	<tag-mappings namespace="http://openxal.org/ui http://openxal.org/ui/html" document="ui">
 		<mapping class="xap.bridges.basic.HtmlHostBridge" name="htmlHost"/>
 
 		<mapping class="xap.bridges.basic.DefsBridge" name="defs"/>
@@ -110,76 +110,6 @@
 
 	</tag-mappings>
 	
-	
-	<!-- IMPORTANT make it so the two namespaces can be space
-	separated instead of listing them twice -->
-	<tag-mappings namespace="http://openxal.org/ui/html" document="ui">
-		<mapping class="xap.bridges.basic.HtmlHostBridge" name="htmlHost"/>
-
-		<mapping class="xap.bridges.basic.DefsBridge" name="defs"/>
-		<mapping class="xap.bridges.basic.HtmlViewBridge" name="htmlView"/>
-		<mapping class="xap.bridges.basic.HtmlViewBridge" name="textView"/>
-		
-		<mapping class="xap.bridges.xap.LabelBridge" name="label"/>
-		<mapping class="xap.bridges.xap.LinkBridge" name="link"/>		
-		<mapping class="xap.bridges.xap.ButtonBridge" name="button"/>
-		<mapping class="xap.bridges.xap.CheckboxBridge" name="checkBox"/>
-		<mapping class="xap.bridges.xap.RadioButtonBridge" name="radioButton"/>
-		<mapping class="xap.bridges.xap.XapComboBoxBridge" name="comboBox"/>
-		<mapping class="xap.bridges.xap.EditableComboBoxBridge" name="editableComboBox"/>
	
-		<mapping class="xap.bridges.xap.ListBoxBridge" name="listBox"/>
-		<mapping class="xap.bridges.xap.ListItemBridge" name="listItem"/>
-	
-		
-		<mapping class="xap.bridges.dojo.VerticalSplitPaneBridge" name="verticalSplitPane"/>
-		<mapping class="xap.bridges.dojo.HorizontalSplitPaneBridge" name="horizontalSplitPane"/>
-		<mapping class="xap.bridges.dojo.SplitChildBridge" name="top"/>
-		<mapping class="xap.bridges.dojo.SplitChildBridge" name="left"/>
-		<mapping class="xap.bridges.dojo.SecondSplitChildBridge" name="bottom"/>
-		<mapping class="xap.bridges.dojo.SecondSplitChildBridge" name="right"/>
-		
-		<mapping class="xap.bridges.dojo.VerticalToolBarBridge" name="verticalToolBar"/>
-		<mapping class="xap.bridges.dojo.HorizontalToolBarBridge" name="horizontalToolBar"/>
-		
-		<mapping class="xap.bridges.dojo.ScrollPaneBridge" name="scrollPane"/>
-		<mapping class="xap.bridges.dojo.DesktopPaneBridge" name="desktopPane"/>
-		<mapping class="xap.bridges.dojo.DesktopPaneBridge" name="rootPane"/>
-		
-		<mapping class="xap.bridges.dojo.TableBridge" name="table"/>	
-		<mapping class="xap.bridges.dojo.TreeTableBridge" name="treeTable"/>
-		<mapping class="xap.bridges.dojo.TreeBridge" name="tree"/>	
-		<mapping class="xap.bridges.dojo.TabPaneBridge" name="tabPane"/>	
-		<mapping class="xap.bridges.dojo.TabBridge" name="tab"/>	
-		<mapping class="xap.bridges.dojo.FreePanelBridge" name="freePane"/>	
-		<mapping class="xap.bridges.dojo.VerticalPanelBridge" name="verticalBoxPane"/>	
-		<mapping class="xap.bridges.dojo.HorizontalPanelBridge" name="horizontalBoxPane"/>

-		<mapping class="xap.bridges.dojo.BorderPanelBridge" name="borderPane"/>	
-		<mapping class="xap.bridges.dojo.TextFieldBridge" name="textField"/>
-		<mapping class="xap.bridges.dojo.PasswordFieldBridge" name="passwordField"/>
-		<mapping class="xap.bridges.dojo.TextAreaBridge" name="textArea"/>
-		
-		<mapping class="xap.bridges.dojo.RowBridge" name="row"/>
-		<mapping class="xap.bridges.dojo.ColumnBridge" name="column"/>
-		<mapping class="xap.bridges.dojo.CellBridge" name="cell"/>
-		
-		<mapping class="xap.bridges.dojo.MenuItemBridge" name="menuItem"/>
-		<mapping class="xap.bridges.dojo.MenuBarBridge" name="menuBar"/>
-		<mapping class="xap.bridges.dojo.MenuBridge" name="menu"/>
-		<mapping class="xap.bridges.dojo.PopupMenuBridge" name="popupMenu"/>
-		<mapping class="xap.bridges.dojo.HorizontalSeparatorBridge" name="horizontalSeparator"/>
-		
-		<mapping class="xap.bridges.dojo.WindowBridge" name="window"/>
-		
-		<mapping class="xap.bridges.dojo.HorizontalFlowPaneBridge" name="horizontalFlowPane"/>
-		<mapping class="xap.bridges.dojo.GridPanelBridge" name="gridPanel"/>
-
-		<!-- for now cell just maps to label and header to button -->
-		
-		<mapping class="xap.bridges.xap.ButtonBridge" name="header"/>
-
-	</tag-mappings>
-
-			
 	<!-- old dojo mappings -->
 	<tag-mappings namespace="http://www.dojotoolkit.org/" document="ui">	
 		<mapping class="xap.bridges.dojo.DojoButtonBridge" name="button"/>

Modified: incubator/xap/trunk/testsrc/xap/taghandling/_TestPluginRegistryImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/taghandling/_TestPluginRegistryImpl.js?view=diff&rev=489485&r1=489484&r2=489485
==============================================================================
--- incubator/xap/trunk/testsrc/xap/taghandling/_TestPluginRegistryImpl.js (original)
+++ incubator/xap/trunk/testsrc/xap/taghandling/_TestPluginRegistryImpl.js Thu Dec 21 14:37:22
2006
@@ -31,11 +31,10 @@
  	var pluginRegistry = new xap.taghandling.PluginRegistryImpl(null);
  	var pluginString = xap.util.HttpUtils.get( "/jsunit/testsrc/xap/taghandling/plugin.xml").responseText;

  	pluginRegistry.addPluginDescription(pluginString);
+ 	
  	var tagMapping = pluginRegistry.getTagMapping("objectDataSource", "http://openxal.org/core/data",
"dataSources");
- 	assertTrue("tag mapping for objectDataSource is com.acme.plugin.data.bridge.DocumentDataSourceBridge",
+ 	assertTrue("tag mapping for objectDataSource is com.acme.plugin.data.bridge.ObjectDataSourceBridge",
  		tagMapping=="com.acme.plugin.data.bridge.ObjectDataSourceBridge");
-
-
  		
  	tagMapping = pluginRegistry.getTagMapping("objectDataSource", "http://openxal.org/core/data1",
"dataSources");
  	assertTrue("tag mapping for objectDataSource with wrong namespace is null",
@@ -45,8 +44,35 @@
  	tagMapping = pluginRegistry.getTagMapping("objectDataSource", "http://openxal.org/core/data",
"dataSources1");
  	assertTrue("tag mapping for objectDataSource with wrong document is null",
  		tagMapping==null);
+ 		
+ 		
+ 	tagMapping = pluginRegistry.getTagMapping("objectDataSource", "namespace2", "dataSources");
+ 	assertTrue("tag mapping for objectDataSource is com.acme.plugin.data.bridge.ObjectDataSourceBridge",
+ 		tagMapping=="com.acme.plugin.data.bridge.ObjectDataSourceBridge");
+
+
+ 		
+ 	tagMapping = pluginRegistry.getTagMapping("objectDataSource", "namespace21", "dataSources");
+ 	assertTrue("tag mapping for objectDataSource with wrong namespace is null",
+ 		tagMapping==null);
+
+ 		
+ 	tagMapping = pluginRegistry.getTagMapping("objectDataSource", "namespace2", "dataSources1");
+ 	assertTrue("tag mapping for objectDataSource with wrong document is null",
+ 		tagMapping==null);
+ 		
+ 		
+ 	tagMapping = pluginRegistry.getTagMapping("binding", "http://openxal.org/core/data", "bindings");
+ 	assertTrue("tag mapping for binding with data namespace is good",
+ 		tagMapping=="com.acme.plugin.data.bridge.BindingBridge");
+ 		
+ 	tagMapping = pluginRegistry.getTagMapping("binding", "namespace2", "bindings");
+ 	assertTrue("tag mapping for binding with namespace2 namespace is null",
+ 		tagMapping==null);
+ 		
+ 		
 
- 	tagMapping = pluginRegistry.getTagMapping("iteratorPlaceHolder",null,"ui");
+ 	tagMapping = pluginRegistry.getTagMapping("iteratorPlaceHolder","http://openxal.org/core/data","ui");
  	assertTrue("tag mapping for iteratorPlaceHolder is special item",
  		tagMapping==xap.taghandling.PluginRegistryImpl.NO_MAPPED_CLASS);
  		

Modified: incubator/xap/trunk/testsrc/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/taghandling/plugin.xml?view=diff&rev=489485&r1=489484&r2=489485
==============================================================================
--- incubator/xap/trunk/testsrc/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/testsrc/xap/taghandling/plugin.xml Thu Dec 21 14:37:22 2006
@@ -1,6 +1,6 @@
 <plugin>
 	<!-- mappings that apply to the document named "dataSources" -->
-	<tag-mappings namespace="http://openxal.org/core/data" document="dataSources">
+	<tag-mappings namespace=" http://openxal.org/core/data  namespace2  " document="dataSources">
 		<mapping class="com.acme.plugin.data.bridge.DocumentDataSourceBridge"
 			name="documentDataSource"/>
 		<mapping class="com.acme.plugin.data.bridge.ObjectDataSourceBridge"
@@ -42,7 +42,7 @@
 	
 	<!-- The iteratorPlaceHolder element is used to keep track of the spot
 		an iterator with an empty dataset will be contributing to. -->
-	<unmapped-tags>
+	<unmapped-tags namespace="http://openxal.org/core/data">
 		<mapping name="iteratorPlaceHolder"/>
 	</unmapped-tags>
 	



Mime
View raw message