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/10/12 22:58:55 UTC
svn commit: r463494 - in /incubator/xap/trunk: WebContent/examples/widgets/
src/xap/bridges/basic/ src/xap/bridges/dojo/ src/xap/bridges/xap/
src/xap/session/ src/xap/taghandling/
Author: jmargaris
Date: Thu Oct 12 15:58:54 2006
New Revision: 463494
URL: http://svn.apache.org/viewvc?view=rev&rev=463494
Log:
popupMenu work
Added:
incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html (with props)
incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal (with props)
incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js (with props)
Removed:
incubator/xap/trunk/src/xap/bridges/xap/MenuBridge.js
Modified:
incubator/xap/trunk/WebContent/examples/widgets/index.html
incubator/xap/trunk/WebContent/examples/widgets/menu.xal
incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js
incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js
incubator/xap/trunk/src/xap/session/ClientSession.js
incubator/xap/trunk/src/xap/taghandling/plugin.xml
Modified: incubator/xap/trunk/WebContent/examples/widgets/index.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/index.html?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/index.html (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/index.html Thu Oct 12 15:58:54 2006
@@ -18,6 +18,7 @@
<li><a href="borderPanel.html"><borderPanel></a></li>
<li><a href="table.html"><table></a></li>
<li><a href="menu.html"><menu></a></li>
+<li><a href="popupMenu.html"><popupMenu></a></li>
</ul>
<br>
Modified: incubator/xap/trunk/WebContent/examples/widgets/menu.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/menu.xal?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/menu.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/menu.xal Thu Oct 12 15:58:54 2006
@@ -12,11 +12,13 @@
<xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
<xm:append select="/xal">
+ <xal:verticalPanel>
<xal:menuBar id="testComponent" height="50px">
<xal:menuBarItem text="Edit">
<xal:menu>
<xal:menuItem text="Cut" onCommand="mco:attributeSetter.reportEvent(event)"/>
<xal:menuItem text="Copy"/>
+ <xal:horizontalSeparator />
<xal:menuItem text="Paste"/>
</xal:menu>
</xal:menuBarItem>
@@ -25,7 +27,12 @@
<xal:menu>
<xal:menuItem text="Open"/>
<xal:menuItem text="Close"/>
- <xal:menuItem text="Preferences..."/>
+ <xal:menuItem text="Preferences.">
+ <xal:menu>
+ <xal:menuItem text="A preference"/>
+ <xal:menuItem text="A different preference"/>
+ </xal:menu>
+ </xal:menuItem>
</xal:menu>
</xal:menuBarItem>
@@ -50,7 +57,7 @@
<!--standard test things -->
<include href="standardButtons.xal" xmlns="http://www.openxal.org/xinclude"/>
-
+ </xal:verticalPanel>
</xm:append>
</xm:modifications>
</xal>
Added: incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html?view=auto&rev=463494
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html (added)
+++ incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html Thu Oct 12 15:58:54 2006
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Button</title>
+
+ <style type="text/css">
+ <!--
+ @import url(../../css/xapDefault.css);
+ -->
+ </style>
+
+ <!-- Keep dojo from trying to scan this whole page for dojoType'd tags: -->
+ <script type="text/javascript">
+ djConfig = {
+ parseWidgets: false
+ };
+ </script>
+
+ <script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
+ <script language="JavaScript" type="text/javascript" src="AttributeTester.js"></script>
+
+ </head>
+
+ <body onload="Xap.createAllPredefinedSessions();">
+ <div xapId="ButtonExample" xapSrc="popupMenu.xal" xapToolkit="dojo" xapContext="../../"></div>
+</body>
+</html>
Propchange: incubator/xap/trunk/WebContent/examples/widgets/popupMenu.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal?view=auto&rev=463494
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal (added)
+++ incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal Thu Oct 12 15:58:54 2006
@@ -0,0 +1,39 @@
+<xal xmlns="http://www.openxal.org/xal" xmlns:xal="http://www.openxal.org/xal">
+
+
+ <mco:mco
+ xmlns:mco="http://www.openxal.org/mco"
+ id="attributeSetter"
+ src="AttributeTester"
+ />
+
+
+
+ <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
+ <xm:append select="/xal">
+ <xal:verticalPanel>
+
+ <xal:defs>
+ <xal:menu id="testComponent">
+ <xal:menuItem text="Cut" id="cut" onCommand="mco:attributeSetter.reportEvent(event)"/>
+ <xal:menuItem text="Copy"/>
+ <xal:horizontalSeparator />
+ <xal:menuItem text="Paste">
+ <xal:menu>
+ <xal:menuItem text="Cut"/> <xal:menuItem text="Copy"/>
+ <xal:horizontalSeparator />
+ <xal:menuItem text="Paste"/>
+ </xal:menu>
+ </xal:menuItem>
+ </xal:menu>
+ </xal:defs>
+
+ <xal:button text="I have a popup" popup="#testComponent"/>
+
+ <!--standard test things -->
+
+ <include href="standardButtons.xal" xmlns="http://www.openxal.org/xinclude"/>
+ </xal:verticalPanel>
+ </xm:append>
+ </xm:modifications>
+</xal>
Propchange: incubator/xap/trunk/WebContent/examples/widgets/popupMenu.xal
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js Thu Oct 12 15:58:54 2006
@@ -386,7 +386,8 @@
return ["x","y","width","height","backgroundColor",
"borderWidth","borderColor","borderStyle","margin",
"padding","color","textDecoration","fontFamily",
- "fontStyle","fontWeight", "fontSize", "textAlign"];
+ "fontStyle","fontWeight", "fontSize", "textAlign",
+ "popup"];
}
xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.getAllowedAttributes = function(){
@@ -554,5 +555,19 @@
/** XML attribute set method for "textAlign" */
xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.setTextAlignAttribute = function(value){
this.getRootDomNode().style.textAlign = value ;
+}
+
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.setPopupAttribute = function(popupId){
+ //TODO fire event
+ //TODO if they have OLD popup need to unregister it!!!
+ popupId = popupId.substring(1);
+ var popupElement = this.getUiDocument().getElementById(popupId);
+ if (!popupElement){
+ return;
+ }
+ var handler = this.getUiContentHandler().getHandlerForElement(popupElement);
+ if (handler && handler instanceof xap.bridges.dojo.MenuBridge){
+ handler.bindDomNode(this.getRootDomNode());
+ }
}
Added: incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js?view=auto&rev=463494
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js Thu Oct 12 15:58:54 2006
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ */
+
+Xap.provide("xap.bridges.basic.DefsBridge");
+
+Xap.require("xap.taghandling.AbstractTagImpl");
+
+/**
+ * @fileoverview This class is a simple placeholder
+ * that other tags get placed under, it does not have a node
+ * in the HTML DOM. Items under defs are items that are usually
+ * referenced such as popup menus.
+ *
+ * @author jmargaris
+ */
+
+/**
+ * @class This class is a simple placeholder
+ * that other tags get placed under, it does not have a node
+ * in the HTML DOM. Items under defs are items that are usually
+ * referenced such as popup menus.
+ *
+ * @constructor
+ */
+xap.bridges.basic.DefsBridge = function() {
+ xap.taghandling.AbstractTagImpl.call(this);
+}
+
+Xap.setupClassAsSubclassOf("xap.bridges.basic.DefsBridge", "xap.taghandling.AbstractTagImpl");
+
+/**
+ * Overridden to call <code>parseInitialChildren</code>
+ */
+xap.bridges.basic.DefsBridge.prototype.init = function() {
+ this.parseInitialChildren( this.getElement() );
+ xap.taghandling.AbstractTagImpl.prototype.init.call( this );
+}
+
+/**
+ * We need this because right now <defs> is added to dom root
+ * which expects components, we either need to check there for
+ * getRootDomNode function or have something like <rootPane>
+ * that UI components go into instead of directly under root.
+ * This doesn't return anything, it just defines the function
+ */
+xap.bridges.basic.DefsBridge.prototype.getRootDomNode = function() {}
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/basic/DefsBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js?view=auto&rev=463494
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js Thu Oct 12 15:58:54 2006
@@ -0,0 +1,84 @@
+/*
+ * 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 menubar peer.
+ */
+
+Xap.provide("xap.bridges.dojo.HorizontalSeparatorBridge");
+
+Xap.require("dojo.widget.MenuBar2");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.HorizontalSeparatorBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.HorizontalSeparatorBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.HorizontalSeparatorBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+ this.getPeer().layoutItem();
+}
+
+xap.bridges.dojo.HorizontalSeparatorBridge.prototype.getPeerString = function(){
+ return "MenuSeparator2" ;
+}
+
+dojo.widget.MenuSeparator2.prototype.postCreate = function(){
+
+ //the dojo version of this calls layoutItem inline, which
+ //gives us an error because we don't have a parent yet
+ //and that code relies on it. SO we move the layoutItem()
+ //call to the init(). TODO is that going to work if tail recursion
+ //is off? Do we care?
+ dojo.html.disableSelection(this.domNode);
+};
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.HorizontalSeparatorBridge.prototype.getNewAllowedAttributes = function(){
+ return [];
+}
+
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/HorizontalSeparatorBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js Thu Oct 12 15:58:54 2006
@@ -52,6 +52,34 @@
return "PopupMenu2" ;
}
+//code copied from PopupMenu2 but that expects an ID insteado of a node
+//which we don't always have.
+//IMPORTANT give each root dom node the same ID as in XAP dom? would be
+//reasonable. Then we can get rid of this
+xap.bridges.dojo.MenuBridge.prototype.bindDomNode = function( node ){
+ dojo.widget.Menu2.OperaAndKonqFixer.fixNode(node);
+
+ dojo.event.kwConnect({
+ srcObj: node,
+ srcFunc: "oncontextmenu",
+ targetObj: this.getPeer(),
+ targetFunc: "onOpen",
+ once: true
+ });
+}
+
+xap.bridges.dojo.MenuBridge.prototype.unbindDomNode = function( node ){
+ dojo.event.kwDisconnect({
+ srcObj: node,
+ srcFunc: "oncontextmenu",
+ targetObj: this.getPeer(),
+ targetFunc: "onOpen",
+ once: true
+ });
+
+ // cleans a fixed node, konqueror and opera
+ dojo.widget.Menu2.OperaAndKonqFixer.cleanNode(node);
+}
/**
*
Modified: incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js Thu Oct 12 15:58:54 2006
@@ -103,3 +103,11 @@
mapper.text = "caption";
return mapper;
}
+
+xap.bridges.dojo.MenuItemBridge.prototype.addChild = function(childHandler, index){
+ var childPeer = childHandler.getPeer();
+ if (childPeer instanceof dojo.widget.PopupMenu2){
+ this.getPeer().submenuId = childHandler.getElement().getAttribute("id");
+ }
+}
+
Modified: incubator/xap/trunk/src/xap/session/ClientSession.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/session/ClientSession.js?view=diff&rev=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/src/xap/session/ClientSession.js (original)
+++ incubator/xap/trunk/src/xap/session/ClientSession.js Thu Oct 12 15:58:54 2006
@@ -304,7 +304,9 @@
}
handler.addChild = function(child, index){
- this.getNodeForChildren().appendChild(child.getRootDomNode());
+ if (child.getRootDomNode()){
+ this.getNodeForChildren().appendChild(child.getRootDomNode());
+ }
}
} else {
parentElementWrapper = new DwtShell( "MainShell", false, null, null, true );
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=463494&r1=463493&r2=463494
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Thu Oct 12 15:58:54 2006
@@ -5,6 +5,8 @@
</tag-mappings>
+ <!-- IMPORTANT move data stuff to separate mapping file -->
+
<!-- Data-source mappings: -->
<tag-mappings namespace="http://www.openxal.org/data" document="dataSources">
<mapping class="xap.data.bridge.ObjectDataSourceBridge" name="objectDataSource"/>
@@ -45,6 +47,7 @@
<!-- default mappings -->
<tag-mappings namespace="http://www.openxal.org/xal" document="xal">
+ <mapping class="xap.bridges.basic.DefsBridge" name="defs"/>
<mapping class="xap.bridges.basic.TextViewBridge" name="textView"/>
<mapping class="xap.bridges.xap.LabelBridge" name="label"/>
@@ -76,7 +79,10 @@
<mapping class="xap.bridges.dojo.MenuBarBridge" name="menuBar"/>
<mapping class="xap.bridges.dojo.MenuBarItemBridge" name="menuBarItem"/>
<mapping class="xap.bridges.dojo.MenuBridge" name="menu"/>
- <!-- mapping class="xap.bridges.dojo.ScrollPaneBridge" name="scrollPane"/ -->
+ <mapping class="xap.bridges.dojo.HorizontalSeparatorBridge" name="horizontalSeparator"/>
+
+
+
<!-- for now cell just maps to label and header to button -->