krysalis-menu/component/src/java/org/krysalis/menu/component MenuBar.java,NONE,1.1 Menu.library,1.1,1.2 MenuBar.jwc,1.1,1.2 MenuItem.html,1.4,1.5 MenuItem.java,1.1,1.2 MenuItem.script,1.1,1.2

Glen Stampoultzis <[email protected]> Thu, 17 Mar 2005 11:51:11 +0000
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-menu/component/src/java/org/krysalis/menu/component
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31560/component/src/java/org/krysalis/menu/component

Modified Files:
	Menu.library MenuBar.jwc MenuItem.html MenuItem.java 
	MenuItem.script 
Added Files:
	MenuBar.java 
Log Message:
Patch to support safari and fix for dynamically generated components

Index: MenuItem.html
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-menu/component/src/java/org/krysalis/menu/component/MenuItem.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MenuItem.html	8 Feb 2005 23:51:56 -0000	1.4
--- MenuItem.html	17 Mar 2005 11:51:09 -0000	1.5
***************
*** 1,4 ****
! <span jwcid="@Script" script="/org/krysalis/menu/component/MenuItem.script" id="ognl:id" submenuid="ognl:submenuId"/>
!     <tr class="menuItem" id="ognl:'menu' + id" jwcid="@Any">
          <td>&nbsp;</td>
          <td><span jwcid="@Conditional" condition="ognl:getBinding('image') != null && getBinding('image').object"><img jwcid="@Image" image="ognl:getBinding('image').object"/></span></td>
--- 1,4 ----
! <span jwcid="@Script" script="/org/krysalis/menu/component/MenuItem.script" id="ognl:getElementId()" submenuid="ognl:submenuId"/>
! <tr class="menuItem" id="ognl:'menu' + getElementId()" jwcid="@Any">
          <td>&nbsp;</td>
          <td><span jwcid="@Conditional" condition="ognl:getBinding('image') != null && getBinding('image').object"><img jwcid="@Image" image="ognl:getBinding('image').object"/></span></td>

Index: MenuItem.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-menu/component/src/java/org/krysalis/menu/component/MenuItem.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MenuItem.java	24 Nov 2004 23:08:39 -0000	1.1
--- MenuItem.java	17 Mar 2005 11:51:09 -0000	1.2
***************
*** 59,62 ****
--- 59,64 ----
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IComponent;
+ import org.apache.tapestry.IMarkupWriter;
+ import org.apache.tapestry.IRequestCycle;
  
  /**
***************
*** 67,70 ****
--- 69,74 ----
          extends BaseComponent
  {
+     private String elementId = null;
+ 
      public boolean isSubmenuProvided()
      {
***************
*** 75,81 ****
      {
          if (getBinding("submenu") != null)
!             return ((IComponent)getBinding("submenu").getObject()).getId();
          else
              return "";
      }
  }
--- 79,108 ----
      {
          if (getBinding("submenu") != null)
!         {
!             IComponent submenu = ((IComponent)getBinding("submenu").getObject());
!             return getElementId( submenu );
!         }
          else
+         {
              return "";
+         }
+     }
+ 
+     private String getElementId( )
+     {
+         return elementId;
+     }
+ 
+     private String getElementId( IComponent submenu )
+     {
+         MenuBar menuBar = MenuBar.get( getPage().getRequestCycle() );
+         return menuBar.getElementId( submenu );
+     }
+ 
+     protected void renderComponent( IMarkupWriter writer, IRequestCycle cycle )
+     {
+         elementId = getElementId( this );
+         
+         super.renderComponent( writer, cycle );
      }
  }

Index: MenuItem.script
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-menu/component/src/java/org/krysalis/menu/component/MenuItem.script,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MenuItem.script	24 Nov 2004 23:08:39 -0000	1.1
--- MenuItem.script	17 Mar 2005 11:51:09 -0000	1.2
***************
*** 109,114 ****
          if (submenuElement)
          {
!             submenuElement.style.top = (topMargin(buttonElement) ) + "px";
!             submenuElement.style.left = (leftMargin(buttonElement) + buttonElement.offsetWidth - 9) + "px";
              addClass( submenuElement, "menuDropDivVisible" );
              currentSubmenu = submenuElement;
--- 109,120 ----
          if (submenuElement)
          {
!             // get top starting from _any_ TD inside the TR (instead of the TR)
!             submenuElement.style.top = (topMargin(buttonElement.cells[0]) ) + "px";
!             // compute "buttonElement.offsetWidth" (for TR) by summing all TD offsetWidths
!             var rowWidth = 0;
!             for ( var i = 0; i < buttonElement.cells.length; ++i ) {
!                 rowWidth += buttonElement.cells[i].offsetWidth;
!             }
!             submenuElement.style.left = (leftMargin(buttonElement) + rowWidth - 9) + "px";
              addClass( submenuElement, "menuDropDivVisible" );
              currentSubmenu = submenuElement;

Index: MenuBar.jwc
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-menu/component/src/java/org/krysalis/menu/component/MenuBar.jwc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MenuBar.jwc	24 Nov 2004 23:08:38 -0000	1.1
--- MenuBar.jwc	17 Mar 2005 11:51:09 -0000	1.2
***************
*** 60,64 ****
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
    
! <component-specification>
  
    <description>
--- 60,64 ----
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
    
! <component-specification class="org.krysalis.menu.component.MenuBar" >
  
    <description>


--- NEW FILE: MenuBar.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2004 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many
   individuals, who decided to donate the code to this project in respect
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/

package org.krysalis.menu.component;

import org.apache.tapestry.BaseComponent;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.util.IdAllocator;

/**
 * @author Glen Stampoultzis
 * @version $Id: MenuBar.java,v 1.1 2005/03/17 11:51:09 gstamp Exp $
 */
public class MenuBar
        extends BaseComponent
{
    private static final String MENU_BAR_REQ_ID = "org.krysalis.menu.component.MenuBar.id";

    private IdAllocator elementIdAllocator = new IdAllocator();

    protected void prepareForRender( IRequestCycle cycle )
    {
        super.prepareForRender( cycle );
        cycle.setAttribute( MENU_BAR_REQ_ID, this );
    }

    public static MenuBar get( IRequestCycle cycle )
    {
        return (MenuBar) cycle.getAttribute( MENU_BAR_REQ_ID );
    }

    public String getElementId(IComponent component)
    {
        String baseId = component.getId();
        String result = elementIdAllocator.allocateId(baseId);
        return result;
    }
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click