[Laszlo-checkins] r10807 - in openlaszlo/trunk/WEB-INF/lps: lfc/kernel/dhtml lfc/services schema server/src/org/openlaszlo/compiler

bargull@openlaszlo.org bargull at openlaszlo.org
Wed Aug 27 08:37:13 PDT 2008


Author: bargull
Date: 2008-08-27 08:37:03 -0700 (Wed, 27 Aug 2008)
New Revision: 10807

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzContextMenuKernel.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzContextMenu.lzs
   openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
Log:
Change 20080826-bargull-lxD by bargull at dell--p4--2-53 on 2008-08-26 00:57:30
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: contextmenu-tag

New Features: LPP-834

Bugs Fixed: LPP-5306

Technical Reviewer: hminsky
QA Reviewer: ptw
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Added support for a "contextmenu"-tag:
- changed LzContextMenu and LzContextMenuItem to final classes, no need for users to access the contextmenu-kernel stuff
- added setters for all properties in both classes
- added super-call in constructor, so contextmenu is placed within the node-hierarchy
- tag contextmenus automcatically try to register themselves as their parent's contextmenu
- tag contextmenuitems automatically add themselves to their parent-contextmenu
- changed dhtml-contextmenu separator from line-break to horizontal-ruler, I suspect this was typo
- changed dhtml-contextmenu minimum-width to 100px to give a prettier output (doesn't work in IE6 due to the limited css-support, though)
- added contextmenu and contextmenuitem to the schema
- added both to lfc-taglist in ClassModel

    

Tests:
added a simple testcase at the bugreport



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzContextMenuKernel.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzContextMenuKernel.lzs	2008-08-27 15:29:34 UTC (rev 10806)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzContextMenuKernel.lzs	2008-08-27 15:37:03 UTC (rev 10807)
@@ -99,7 +99,7 @@
         var cm = items[i].kernel;
         var v = cm.cmenuitem;
         if (v.visible != true) continue; 
-        if (v.separatorBefore) o += '<br/>';
+        if (v.separatorBefore) o += '<hr/>';
 
         var caption = v.caption;
         // Don't display the same item twice (matches swf behavior)

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-08-27 15:29:34 UTC (rev 10806)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-08-27 15:37:03 UTC (rev 10807)
@@ -262,7 +262,8 @@
     fontFamily: 'Verdana,Vera,sans-serif',
     fontSize: '13px',
     margin: '2px',
-    color: '#999'
+    color: '#999',
+    minWidth: '100px'
 };
 
 LzSprite.prototype.uid = 0;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzContextMenu.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzContextMenu.lzs	2008-08-27 15:29:34 UTC (rev 10806)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzContextMenu.lzs	2008-08-27 15:37:03 UTC (rev 10807)
@@ -17,30 +17,59 @@
   *
   * @shortdesc A contextual menu
   */
-class LzContextMenu extends LzNode {
+public final class LzContextMenu extends LzNode {
 
-function LzContextMenu (del:LzDelegate = null) {
-    this.kernel = new LzContextMenuKernel(this);
-
-    this.items = [];
-    // set callback
-    this.setDelegate(del);
-}
-
 /** @access private
   * @modifiers override 
   */
 static var tagname = 'contextmenu';
 
+/** @access private */
+static var attributes = new LzInheritedHash(LzNode.attributes);
+
 /**
   * @lzxtype event
   */
 var onmenuopen:LzDeclaredEventClass = LzDeclaredEvent;
 
+/** @access private */
 var kernel:LzContextMenuKernel = null;
+/** @access private */
 var items:Array = null;
 
+function LzContextMenu (del:* = null, attrs:Object? = null, children:Array? = null, instcall:Boolean = false) {
+    // NOTE: [20080825 anba] for bwcomp we also accept a LzDelegate as the first argument
+    super(del is LzNode ? del cast LzNode : null, del is LzNode ? attrs : {delegate: del}, children, instcall);
+}
 
+/** @access private */
+override function construct (parent, args) {
+    super.construct(parent, args);
+    
+    this.kernel = new LzContextMenuKernel(this);
+
+    this.items = [];
+    
+    var del:* = (args && args['delegate']) || null;
+    delete args['delegate'];
+    
+    // set callback
+    this.setDelegate(del);
+}
+
+/** @access private */
+override function init () {
+    super.init();
+    
+    var p:LzNode = this.parent;
+    if (p && p is LzView) {
+        (p cast LzView).setContextMenu(this);
+    }
+}
+
+/** @access private */
+function $lzc$set_delegate (delegate:*) :void { this.setDelegate(delegate); }
+
 /**
   * Sets the delegate which will be called when the menu is opened
   * @param LzDelegate delegate: delegate which is executed when item is selected. An
@@ -118,22 +147,59 @@
   * 
   * @shortdesc A menu item within a context menu
   */
-class LzContextMenuItem extends LzNode {
+public final class LzContextMenuItem extends LzNode {
 
-function LzContextMenuItem (title:String, del:*) {
-    this.kernel = new LzContextMenuItemKernel(this, title, del);
-};
-
 /** @access private
   * @modifiers override 
   */
 static var tagname = 'contextmenuitem';
 
+/** @access private */
+static var attributes = new LzInheritedHash(LzNode.attributes);
+
+/** @access public */
 var onselect:LzDeclaredEventClass = LzDeclaredEvent;
 
+/** @access private */
 var kernel:LzContextMenuItemKernel = null;
 
+function LzContextMenuItem (title:*, del:Object? = null, children:Array? = null, instcall:Boolean = false) {
+    // NOTE: [20080825 anba] for bwcomp we also accept a String 
+    // and a LzDelegate/Function as the first two arguments
+    super(title is LzNode ? title cast LzNode : null, title is LzNode ? del : {title: title, delegate: del}, children, instcall);
+};
 
+/** @access private */
+override function construct (parent, args) {
+    super.construct(parent, args);
+    
+    var title:String = (args && args['title']) || "";
+    delete args['title'];
+    var del:* = (args && args['delegate']) || null;
+    delete args['delegate'];
+    
+    this.kernel = new LzContextMenuItemKernel(this, title, del);
+    
+    if (parent && parent is LzContextMenu) {
+        parent.addItem(this);
+    }
+}
+
+/** @access private */
+function $lzc$set_delegate (delegate:*) :void { this.setDelegate(delegate); }
+
+/** @access private */
+function $lzc$set_caption (caption:String) :void { this.setCaption(caption); }
+
+/** @access private */
+function $lzc$set_enabled (val:Boolean) :void { this.setEnabled(val); }
+
+/** @access private */
+function $lzc$set_separatorbefore (val:Boolean) :void { this.setSeparatorBefore(val); }
+
+/** @access private */
+function $lzc$set_visible (val:Boolean) :void { this.setVisible(val); }
+
 /**
   * LzContextMenuItem.setDelegate
   * Sets the delegate which will be called when the menu item is selected

Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-08-27 15:29:34 UTC (rev 10806)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-08-27 15:37:03 UTC (rev 10807)
@@ -104,6 +104,7 @@
     <element>doc</element>
     <element>node</element>
     <element>splash</element>
+    <element>contextmenu</element>
     <!-- soon to be deprecated -->
     <element>connectiondatasource</element>
   </containsElements>
@@ -318,6 +319,7 @@
     <element>text</element>
     <element>inputtext</element>
     <element>node</element>
+    <element>contextmenu</element>
   </containsElements>
 
   <method name="$lzc$getAttributeRelative_dependencies"/>
@@ -1096,6 +1098,24 @@
   <attribute name="showInternalProperties" type="boolean" value="false"/>
 </interface>
 
+<interface name="contextmenu" extends="node" >
+  <event name="onmenuopen" />
+  
+  <attribute name="delegate" type="expression" value="null" />
+  
+  <containsElements>
+    <element>contextmenuitem</element>
+  </containsElements>
+</interface>
 
+<interface name="contextmenuitem" extends="node" >
+  <event name="onselect" />
+  
+  <attribute name="delegate" type="expression" value="null" />
+  <attribute name="caption" type="string" value="" />
+  <attribute name="enabled" type="boolean" value="true" />
+  <attribute name="separatorbefore" type="boolean" value="false" />
+  <attribute name="visible" type="boolean" value="true" />
+</interface>
 
 </library>

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2008-08-27 15:29:34 UTC (rev 10806)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2008-08-27 15:37:03 UTC (rev 10807)
@@ -135,6 +135,8 @@
     LFCTag2JSClass.put("datasource", "LzDatasource");
     LFCTag2JSClass.put("lzhttpdataprovider", "LzHTTPDataProvider");
     LFCTag2JSClass.put("import", "LzLibrary");
+    LFCTag2JSClass.put("contextmenu", "LzContextMenu");
+    LFCTag2JSClass.put("contextmenuitem", "LzContextMenuItem");
   }
 
   public static String LZXTag2JSClass(String s) {



More information about the Laszlo-checkins mailing list