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 01:48:56 UTC
svn commit: r463102 - in /incubator/xap/trunk: WebContent/examples/widgets/
src/xap/bridges/dojo/ src/xap/taghandling/
Author: jmargaris
Date: Wed Oct 11 18:48:55 2006
New Revision: 463102
URL: http://svn.apache.org/viewvc?view=rev&rev=463102
Log:
first shot at some menus
Added:
incubator/xap/trunk/WebContent/examples/widgets/menu.html (with props)
incubator/xap/trunk/WebContent/examples/widgets/menu.xal (with props)
incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js (with props)
incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js (with props)
Modified:
incubator/xap/trunk/WebContent/examples/widgets/index.html
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=463102&r1=463101&r2=463102
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/index.html (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/index.html Wed Oct 11 18:48:55 2006
@@ -17,6 +17,7 @@
<li><a href="horizontalPanel.html"><horizontalPanel></a></li>
<li><a href="borderPanel.html"><borderPanel></a></li>
<li><a href="table.html"><table></a></li>
+<li><a href="menu.html"><menu></a></li>
</ul>
<br>
Added: incubator/xap/trunk/WebContent/examples/widgets/menu.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/menu.html?view=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/menu.html (added)
+++ incubator/xap/trunk/WebContent/examples/widgets/menu.html Wed Oct 11 18:48:55 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="menu.xal" xapToolkit="dojo" xapContext="../../"></div>
+</body>
+</html>
Propchange: incubator/xap/trunk/WebContent/examples/widgets/menu.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/WebContent/examples/widgets/menu.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/menu.xal?view=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/menu.xal (added)
+++ incubator/xap/trunk/WebContent/examples/widgets/menu.xal Wed Oct 11 18:48:55 2006
@@ -0,0 +1,56 @@
+<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: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:menuItem text="Paste"/>
+ </xal:menu>
+ </xal:menuBarItem>
+
+ <xal:menuBarItem text="File">
+ <xal:menu>
+ <xal:menuItem text="Open"/>
+ <xal:menuItem text="Close"/>
+ <xal:menuItem text="Preferences..."/>
+ </xal:menu>
+ </xal:menuBarItem>
+
+ <xal:menuBarItem text="Format">
+ <xal:menu>
+ <xal:menuItem text="Cut"/>
+ <xal:menuItem text="Copy"/>
+ <xal:menuItem text="Paste"/>
+ </xal:menu>
+ </xal:menuBarItem>
+
+ <xal:menuBarItem text="Run">
+ <xal:menu>
+ <xal:menuItem text="Open"/>
+ <xal:menuItem text="Close"/>
+ <xal:menuItem text="Preferences..."/>
+ </xal:menu>
+ </xal:menuBarItem>
+
+ </xal:menuBar>
+
+ <!--standard test things -->
+
+ <include href="standardButtons.xal" xmlns="http://www.openxal.org/xinclude"/>
+
+ </xm:append>
+ </xm:modifications>
+</xal>
Propchange: incubator/xap/trunk/WebContent/examples/widgets/menu.xal
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js?view=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js Wed Oct 11 18:48:55 2006
@@ -0,0 +1,71 @@
+/*
+ * 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.MenuBarBridge");
+
+Xap.require("dojo.widget.MenuBar2");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.MenuBarBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.MenuBarBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.MenuBarBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+}
+
+xap.bridges.dojo.MenuBarBridge.prototype.getPeerString = function(){
+ return "MenuBar2" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.MenuBarBridge.prototype.getNewAllowedAttributes = function(){
+ return [];
+}
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/MenuBarBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js?view=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js Wed Oct 11 18:48:55 2006
@@ -0,0 +1,124 @@
+/*
+ * 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.MenuBarItemBridge");
+
+Xap.require("dojo.widget.MenuBar2");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.MenuBarItemBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.MenuBarItemBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+dojo.widget.MenuBarItem2.prototype.layoutItem = function(item_h){
+ var label_w = dojo.style.getOuterWidth(this.labelNode.childNodes[0]);
+ label_w += 20;
+
+
+ var clientLeft = dojo.style.getPixelValue(this.domNode, "padding-left", true);
+ var clientTop = dojo.style.getPixelValue(this.domNode, "padding-top", true);
+
+ this.labelNode.style.left = clientLeft + 'px';
+
+ dojo.style.setOuterHeight(this.labelNode, item_h);
+ dojo.style.setContentWidth(this.domNode, label_w);
+ dojo.style.setContentHeight(this.domNode, item_h);
+
+ this.labelNode.style.left = '0px';
+
+ dojo.style.setOuterWidth(this.targetNode, label_w);
+ dojo.style.setOuterHeight(this.targetNode, item_h);
+}
+
+xap.bridges.dojo.MenuBarItemBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+}
+
+xap.bridges.dojo.MenuBarItemBridge.prototype.getPeerString = function(){
+ return "MenuBarItem2" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+xap.bridges.dojo.MenuBarItemBridge.prototype.getNewAllowedAttributes = function(){
+ return ["text"];
+}
+
+
+xap.bridges.dojo.MenuBarItemBridge.prototype.setTextAttribute = function( text ){
+
+ var peer = this.getPeer();
+
+ if (!peer || !peer.labelShadowNode){
+ return;
+ }
+ if (peer.labelNode.childNodes[0].childNodes[0]){
+ peer.labelNode.childNodes[0].childNodes[0].value = text;
+ }
+
+ if (peer.labelShadowNode){
+ peer.labelShadowNode.childNodes[0].value = text;
+ }
+}
+
+
+/**
+ *
+ * @return an object mapping allowed initial
+ * XAL properties to their Dojo equivalents
+ */
+xap.bridges.dojo.MenuBarItemBridge.prototype.getXalToToolkitMapper = function(){
+ var mapper = this.superclass.getXalToToolkitMapper.call(this);
+ mapper.text = "caption";
+ return mapper;
+}
+
+
+xap.bridges.dojo.MenuBarItemBridge.prototype.addChild = function(childHandler, index){
+ var childPeer = childHandler.getPeer();
+ if (childPeer instanceof dojo.widget.PopupMenu2){
+ this.getPeer().submenuId = childHandler.getElement().getAttribute("id");
+ }
+}
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/MenuBarItemBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js Wed Oct 11 18:48:55 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.MenuBridge");
+
+Xap.require("dojo.widget.MenuBar2");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.MenuBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.MenuBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.MenuBridge.prototype.init = function() {
+ this.superclass.init.call(this);
+}
+
+xap.bridges.dojo.MenuBridge.prototype.getPeerString = function(){
+ return "PopupMenu2" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.MenuBridge.prototype.getNewAllowedAttributes = function(){
+ return [];
+}
+
+
+
+
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/MenuBridge.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=auto&rev=463102
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.js Wed Oct 11 18:48:55 2006
@@ -0,0 +1,105 @@
+/*
+ * 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.MenuItemBridge");
+
+Xap.require("dojo.widget.MenuBar2");
+Xap.require("xap.session.ClientEvent");
+
+ /**
+ * @fileoverview
+ *
+ * A bridge class with dojo toolkit box panel peer.
+ */
+
+xap.bridges.dojo.MenuItemBridge= function() {
+ xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.MenuItemBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
+
+
+
+xap.bridges.dojo.MenuItemBridge.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(), "onClick",this,"onClick");
+}
+
+xap.bridges.dojo.MenuItemBridge.prototype.getPeerString = function(){
+ return "MenuItem2" ;
+}
+
+
+/**
+ *
+ *
+ * Attribute definitions
+ *
+ */
+
+
+xap.bridges.dojo.MenuItemBridge.prototype.getNewAllowedAttributes = function(){
+ return ["text"];
+}
+
+
+xap.bridges.dojo.MenuItemBridge.prototype.setTextAttribute = function( text ){
+
+ var peer = this.getPeer();
+
+ if (!peer || !peer.labelShadowNode){
+ return;
+ }
+
+
+ if (peer.labelNode.childNodes[0].childNodes[0]){
+ peer.labelNode.childNodes[0].childNodes[0].value = text;
+ }
+
+ if (peer.labelShadowNode){
+ peer.labelShadowNode.childNodes[0].value = text;
+ }
+}
+
+
+xap.bridges.dojo.MenuItemBridge.prototype.onClick = function( ){
+ var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
+ this.fireEvent("onCommand",null,null,clientEvent);
+}
+
+/**
+ *
+ * @return an object mapping allowed initial
+ * XAL properties to their Dojo equivalents
+ */
+xap.bridges.dojo.MenuItemBridge.prototype.getXalToToolkitMapper = function(){
+ var mapper = this.superclass.getXalToToolkitMapper.call(this);
+ mapper.text = "caption";
+ return mapper;
+}
Propchange: incubator/xap/trunk/src/xap/bridges/dojo/MenuItemBridge.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?view=diff&rev=463102&r1=463101&r2=463102
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Wed Oct 11 18:48:55 2006
@@ -71,6 +71,11 @@
<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.MenuBarItemBridge" name="menuBarItem"/>
+ <mapping class="xap.bridges.dojo.MenuBridge" name="menu"/>
<!-- mapping class="xap.bridges.dojo.ScrollPaneBridge" name="scrollPane"/ -->
<!-- for now cell just maps to label and header to button -->