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 jm...@apache.org on 2006/09/01 19:27:11 UTC
svn commit: r439431 - in /incubator/xap/trunk/src: dojo/src/widget/
xap/bridges/dojo/ xap/components/dojo/ xap/taghandling/
Author: jmargaris
Date: Fri Sep 1 12:27:10 2006
New Revision: 439431
URL: http://svn.apache.org/viewvc?rev=439431&view=rev
Log:
new widgets and examples
Added:
incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js (with props)
incubator/xap/trunk/src/xap/components/dojo/TextField.js (with props)
Modified:
incubator/xap/trunk/src/dojo/src/widget/TabContainer.js
incubator/xap/trunk/src/xap/bridges/dojo/SplitPaneBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/TabPaneBridge.js
incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js
incubator/xap/trunk/src/xap/taghandling/plugin.xml
Modified: incubator/xap/trunk/src/dojo/src/widget/TabContainer.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/widget/TabContainer.js?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/dojo/src/widget/TabContainer.js (original)
+++ incubator/xap/trunk/src/dojo/src/widget/TabContainer.js Fri Sep 1 12:27:10 2006
@@ -84,7 +84,7 @@
}
},
- addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
+ addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
this._setupTab(child);
dojo.widget.html.TabContainer.superclass.addChild.call(this,child, overrideContainerNode, pos, ref, insertIndex);
Added: incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js?rev=439431&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js Fri Sep 1 12:27:10 2006
@@ -0,0 +1,88 @@
+/*
+ * 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 textfield peer.
+ */
+
+Xap.provide("xap.bridges.dojo.PasswordFieldBridge");
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.components.dojo.PasswordField");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.PasswordFieldBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.PasswordFieldBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.PasswordFieldBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+
+ //add listener last so we don't fire for the initial set
+ dojo.event.connect(this.getPeer(), "onblur",this,"onblur");
+}
+
+xap.bridges.dojo.PasswordFieldBridge.prototype.getPeerString = function(){
+ return "PasswordField" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.PasswordFieldBridge.prototype.getNewAllowedAttributes = function(){
+ return ["text"];
+}
+
+xap.bridges.dojo.PasswordFieldBridge.prototype.setTextAttribute = function( value ){
+ this.getPeer().setText(value);
+}
+
+xap.bridges.dojo.PasswordFieldBridge.prototype.onblur = function( ){
+ var text = this.getPeer().getText();
+ this.writeBackAttribute("text",text);
+ var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
+ clientEvent.text = text;
+ this.fireEvent("onEdit",null,null,clientEvent);
+}
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/PasswordFieldBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/xap/bridges/dojo/SplitPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/SplitPaneBridge.js?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/SplitPaneBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/SplitPaneBridge.js Fri Sep 1 12:27:10 2006
@@ -62,14 +62,6 @@
return mappings;
}
-//TODO we need to use the addchild method instead here
-//to add children to the split pane
-xp.bridges.dojo.SplitPaneBridge.prototype.getNodeForChildren = function(){
-// This is the large pane in the middle of the widget, and so the best parent for other
-// components:
- return this.getRootDomNode() ;
-}
-
/** XML attribute set method for "width" */
xap.bridges.dojo.SplitPaneBridge.prototype.setWidthAttribute = function(value){
this.getRootDomNode().style.width = value ;
Modified: incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js Fri Sep 1 12:27:10 2006
@@ -24,7 +24,7 @@
Xap.provide("xap.bridges.dojo.Tab");
Xap.require("xap.bridges.dojo.DojoWidgetBridge");
-Xap.require("dojo.widget.LayoutContainer");
+Xap.require("xap.components.dojo.FreePanel");
@@ -36,6 +36,9 @@
xap.bridges.dojo.TabBridge= function() {
xap.bridges.dojo.DojoWidgetBridge.call(this);
+
+ //prevent firing onSelect for tabs that are already selected
+ this._wasSelected = false;
}
@@ -46,23 +49,39 @@
-xap.bridges.dojo.TabBridge.prototype.getPeerString = function(){
- return "LayoutContainer" ;
-}
+xap.bridges.dojo.TabBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+ var parentElement = this.getElement().parentNode;
+ var parentHandler = this.getUiContentHandler().getHandlerForElement( parentElement );
+ this._tabContainer = parentHandler.getPeer();
+
+ //add listener last so we don't fire for the initial set
+ dojo.event.connect(this._tabContainer, "selectTab",this,"onSelect");
+}
+xap.bridges.dojo.TabBridge.prototype.unload = function(){
+ dojo.event.disconnect(this._tabContainer, "selectTab",this,"onSelect");
+}
-/**
- *
- * @return an object mapping allowed XAL properties to their Dojo equivalents
- */
-xap.bridges.dojo.TabBridge.prototype.getXalToToolkitMapper = function(){
+xap.bridges.dojo.TabBridge.prototype.onSelect = function(){
- //the initial attribute text maps to the label property
- var mappings = this.superclass.getXalToToolkitMapper();
- mappings.text = "label";
- return mappings;
+ if (this._tabContainer.selectedTabWidget == this.getPeer() && !this._wasSelected){
+ this.writeBackAttribute("selected","true");
+ this.fireEvent("onSelect");
+ this._wasSelected = true;
+ }
+ else{
+ this.writeBackRemoveAttribute("selected");
+ this._wasSelected = false;
+ }
+}
+
+
+xap.bridges.dojo.TabBridge.prototype.getPeerString = function(){
+ return "FreePanel" ;
}
+
/**
*
@@ -72,11 +91,23 @@
*/
-/**
- * No new dynamic attributes
- */
xap.bridges.dojo.TabBridge.prototype.getNewAllowedAttributes = function(){
- return [];
+ return ["text", "selected"];
+}
+
+//TODO make dynamic
+xap.bridges.dojo.TabBridge.prototype.setTextAttribute = function(value){
+ this.getPeer().label = value;
+}
+
+xap.bridges.dojo.TabBridge.prototype.setSelectedAttribute = function(value){
+
+ //TODO if this is set programitically we don't want to fire
+ //an event, maybe some goofy flag like "IS_PARSING" would be ok
+ this.getPeer().selected=true; //hint for tab container
+ if (this._tabContainer){
+ this._tabContainer.selectTab(this.getPeer());
+ }
}
Modified: incubator/xap/trunk/src/xap/bridges/dojo/TabPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TabPaneBridge.js?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TabPaneBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TabPaneBridge.js Fri Sep 1 12:27:10 2006
@@ -50,6 +50,20 @@
return "TabContainer" ;
}
+xap.bridges.dojo.TabPaneBridge.prototype.addChild = function(childHandler, index){
+ var oldSelectedTab = this.getPeer().selectedTabWidget;
+ this.superclass.addChild.call(this,childHandler, index );
+ var newSelectedTab = this.getPeer().selectedTabWidget;
+
+ //after a child is added if some new tab is selected
+ //we select it here because tabContainer doesn't seem to handle
+ //that except for one time in postCreate
+ if(newSelectedTab && ( newSelectedTab!=oldSelectedTab) ){
+ this.getPeer().selectTab(newSelectedTab, true);
+ }
+}
+
+
/** XML attribute set method for "width" */
xap.bridges.dojo.TabPaneBridge.prototype.setWidthAttribute = function(value){
Added: incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js?rev=439431&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js Fri Sep 1 12:27:10 2006
@@ -0,0 +1,88 @@
+/*
+ * 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 textfield peer.
+ */
+
+Xap.provide("xap.bridges.dojo.TextAreaBridge");
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.components.dojo.TextArea");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.TextAreaBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.TextAreaBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.TextAreaBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+
+ //add listener last so we don't fire for the initial set
+ dojo.event.connect(this.getPeer(), "onblur",this,"onblur");
+}
+
+xap.bridges.dojo.TextAreaBridge.prototype.getPeerString = function(){
+ return "TextArea" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.TextAreaBridge.prototype.getNewAllowedAttributes = function(){
+ return ["text"];
+}
+
+xap.bridges.dojo.TextAreaBridge.prototype.setTextAttribute = function( value ){
+ this.getPeer().setText(value);
+}
+
+xap.bridges.dojo.TextAreaBridge.prototype.onblur = function( ){
+ var text = this.getPeer().getText();
+ this.writeBackAttribute("text",text);
+ var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
+ clientEvent.text = text;
+ this.fireEvent("onEdit",null,null,clientEvent);
+}
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js?rev=439431&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js Fri Sep 1 12:27:10 2006
@@ -0,0 +1,88 @@
+/*
+ * 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 textfield peer.
+ */
+
+Xap.provide("xap.bridges.dojo.TextFieldBridge");
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.components.dojo.TextField");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.TextFieldBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.TextFieldBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.TextFieldBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+
+ //add listener last so we don't fire for the initial set
+ dojo.event.connect(this.getPeer(), "onblur",this,"onblur");
+}
+
+xap.bridges.dojo.TextFieldBridge.prototype.getPeerString = function(){
+ return "TextField" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.TextFieldBridge.prototype.getNewAllowedAttributes = function(){
+ return ["text"];
+}
+
+xap.bridges.dojo.TextFieldBridge.prototype.setTextAttribute = function( value ){
+ this.getPeer().setText(value);
+}
+
+xap.bridges.dojo.TextFieldBridge.prototype.onblur = function( ){
+ var text = this.getPeer().getText();
+ this.writeBackAttribute("text",text);
+ var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
+ clientEvent.text = text;
+ this.fireEvent("onEdit",null,null,clientEvent);
+}
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js (original)
+++ incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js Fri Sep 1 12:27:10 2006
@@ -20,37 +20,78 @@
dojo.lang.extend(xap.components.dojo.BorderPanel, {
templateString: '<table><tr align="center" valign="center">'+
- '<td colspan="3" dojoAttachPoint="north"></td></tr>' +
- '<tr align="center" valign="center" style="height:70%">'+
- '<td dojoAttachPoint="west"></td><td style="width:70%" dojoAttachPoint="center"></td><td dojoAttachPoint="east"></td></tr>' +
- '<tr align="center" valign="center"><td colspan="3" dojoAttachPoint="south"></tr></td></table>',
+ '<td colspan="3" dojoAttachPoint="north" style="height:1px"></td></tr>' +
+ '<tr align="center" valign="center"">'+
+ '<td dojoAttachPoint="west" style="width:1px"></td><td dojoAttachPoint="center" style="height:99%;width:99%"></td><td style="width:1px" dojoAttachPoint="east"></td></tr>' +
+ '<tr align="center" valign="center"><td colspan="3" style="height:1px" dojoAttachPoint="south"></tr></td></table>',
templateCssPath: null ,
widgetType: "BorderPanel",
isContainer: true,
addChild: function(child, position){
+
+ var adjustWidth = false;
+ var adjustHeight = false;
if (position=="north"){
this.containerNode = this.north;
+ adjustWidth = true;
}
else if (position=="south"){
this.containerNode = this.south;
+ adjustWidth = true;
}
else if (position=="east"){
this.containerNode = this.east;
+ adjustHeight = true;
}
else if (position=="west"){
this.containerNode = this.west;
+ adjustHeight = true;
}
else{
this.containerNode = this.center;
+ adjustWidth = true;
+ adjustHeight = true;
+ }
+
+ //if we already have child nodes that's bad!
+ if (this.containerNode.childNodes.length!=0){
+ return;
}
- child.domNode.style.width="100%";
- child.domNode.style.height="100%";
+
+ //IMPORTANT should we do this in a setTimeout() after
+ //we give the table a chance to layout first? probably
+ if (adjustWidth){
+ child.domNode.style.width="100%";
+ }
+ if (adjustHeight){
+ child.domNode.style.height="100%";
+ }
xap.components.dojo.BorderPanel.superclass.addChild.call(this,child);
- }
+ },
+
+ removeChild: function(child) {
+ var containerNode = child.domNode.parentNode;
+ xap.components.dojo.BorderPanel.superclass.removeChild.call(this,child);
+ resetNode(containerNode);
+ },
+
+ resetNode : function(containerNode){
+ var nodeStyle = containerNode.style;
+ if (containerNode==this.north || containerNode==this.south){
+ nodeStyle.width="";
+ nodeStyle.height="1px";
+ }
+ else if (containerNode==this.east || containerNode==this.west){
+ nodeStyle.width="1px";
+ nodeStyle.height="";
+ }
+ else{
+ nodeStyle.width= "99%";
+ nodeStyle.height = "99%";
+ }
+ }
}
-);
-
-
+);
\ No newline at end of file
Added: incubator/xap/trunk/src/xap/components/dojo/TextField.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/components/dojo/TextField.js?rev=439431&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/components/dojo/TextField.js (added)
+++ incubator/xap/trunk/src/xap/components/dojo/TextField.js Fri Sep 1 12:27:10 2006
@@ -0,0 +1,39 @@
+//IMPORTANT move this to some shared area
+dojo.widget.manager.registerWidgetPackage("xap.components.dojo");
+
+Xap.provide("xap.components.dojo.TextField");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.event");
+
+dojo.widget.tags.addParseTreeHandler("dojo:TextField");
+
+xap.components.dojo.TextField = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(xap.components.dojo.TextField, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(xap.components.dojo.TextField, {
+
+ templateString: '<input type="text" dojoAttachEvent="onblur"></input>',
+ templateCssPath: null ,
+ widgetType: "TextField",
+ isContainer: false,
+
+ //hook for attach event
+ onblur: function(){
+ },
+
+ setText: function( text ){
+ this.domNode.value = text;
+ },
+
+ getText: function(){
+ return this.domNode.value;
+ }
+}
+);
\ No newline at end of file
Propchange: incubator/xap/trunk/src/xap/components/dojo/TextField.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?rev=439431&r1=439430&r2=439431&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Fri Sep 1 12:27:10 2006
@@ -34,6 +34,9 @@
<mapping class="xap.bridges.dojo.VerticalPanelBridge" name="verticalPanel"/>
<mapping class="xap.bridges.dojo.HorizontalPanelBridge" name="horizontalPanel"/>
<mapping class="xap.bridges.dojo.BorderPanelBridge" name="borderPanel"/>
+ <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.basic.DomNodeBridge" name="dom"/>
<mapping class="xap.bridges.dojo.DojoDatePickerBridge" name="datePicker"/>