You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/03/25 21:18:47 UTC

svn commit: r927581 - in /myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago: internal/component/AbstractUIPopup.java renderkit/css/Style.java taglib/component/PopupTagDeclaration.java

Author: lofwyr
Date: Thu Mar 25 20:18:47 2010
New Revision: 927581

URL: http://svn.apache.org/viewvc?rev=927581&view=rev
Log:
TOBAGO-134: Internal z-index support for popups.

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupTagDeclaration.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java?rev=927581&r1=927580&r2=927581&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIPopup.java Thu Mar 25 20:18:47 2010
@@ -17,16 +17,11 @@ package org.apache.myfaces.tobago.intern
  * limitations under the License.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.compat.InvokeOnComponent;
-import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.ComponentTypes;
-import org.apache.myfaces.tobago.component.CreateComponentUtils;
-import org.apache.myfaces.tobago.component.DeprecatedDimension;
-import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.OnComponentPopulated;
-import org.apache.myfaces.tobago.component.Position;
-import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.*;
 import org.apache.myfaces.tobago.internal.ajax.AjaxComponent;
 import org.apache.myfaces.tobago.internal.layout.LayoutUtils;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
@@ -45,19 +40,34 @@ import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
 
-public abstract class AbstractUIPopup extends UIPanelBase 
-    implements OnComponentPopulated, NamingContainer, AjaxComponent, InvokeOnComponent,
+public abstract class AbstractUIPopup extends UIPanelBase
+    implements OnComponentCreated, OnComponentPopulated, NamingContainer, AjaxComponent, InvokeOnComponent,
     DeprecatedDimension, Position, LayoutContainer {
 
+  private static final Log LOG = LogFactory.getLog(AbstractUIPopup.class);
+
+  private static final String Z_INDEX = AbstractUIPopup.class.getName() + ".Z_INDEX";
+
   private boolean activated;
 
+  public void onComponentCreated(FacesContext facesContext) {
+    Integer zIndex = (Integer) facesContext.getExternalContext().getRequestMap().get(Z_INDEX);
+    if (zIndex == null) {
+      zIndex = 1;
+    } else {
+      zIndex++;
+    }
+    setZIndex(zIndex);
+    facesContext.getExternalContext().getRequestMap().put(Z_INDEX, zIndex);
+  }
+
   public void onComponentPopulated(FacesContext facesContext) {
     if (getLayoutManager() == null) {
       setLayoutManager(CreateComponentUtils.createAndInitLayout(
           facesContext, ComponentTypes.GRID_LAYOUT, RendererTypes.GRID_LAYOUT));
     }
   }
-  
+
   public List<LayoutComponent> getComponents() {
     return LayoutUtils.findLayoutChildren(this);
   }
@@ -66,6 +76,7 @@ public abstract class AbstractUIPopup ex
     this.activated = activated;
   }
 
+  @Override
   public void processDecodes(FacesContext facesContext) {
     if (isSubmitted()) {
       for (Iterator it = getFacetsAndChildren(); it.hasNext();) {
@@ -81,6 +92,7 @@ public abstract class AbstractUIPopup ex
     }
   }
 
+  @Override
   public boolean isRendered() {
     if (FacesUtils.hasValueBindingOrValueExpression(this, "rendered")) {
       return (Boolean)
@@ -114,19 +126,21 @@ public abstract class AbstractUIPopup ex
   }
 
 
+  @Override
   public void processValidators(FacesContext context) {
     if (isSubmitted()) {
       for (Iterator it = getFacetsAndChildren(); it.hasNext();) {
         UIComponent childOrFacet = (UIComponent) it.next();
         childOrFacet.processValidators(context);
       }
-      //TODO: check if validation has faild and reset rendered if needed
+      //TODO: check if validation has failed and reset rendered if needed
       if (context.getRenderResponse()) {
         setActivated(true);
       }
     }
   }
 
+  @Override
   public void processUpdates(FacesContext context) {
     if (isSubmitted()) {
       for (Iterator it = getFacetsAndChildren(); it.hasNext();) {
@@ -136,6 +150,7 @@ public abstract class AbstractUIPopup ex
     }
   }
 
+  @Override
   public Object saveState(FacesContext context) {
     Object[] saveState = new Object[2];
     saveState[0] = super.saveState(context);
@@ -143,35 +158,39 @@ public abstract class AbstractUIPopup ex
     return saveState;
   }
 
+  @Override
   public void restoreState(FacesContext context, Object savedState) {
     Object[] values = (Object[]) savedState;
     super.restoreState(context, values[0]);
     activated = (Boolean) values[1];
   }
 
+  @Override
   public void encodeEnd(FacesContext context) throws IOException {
     super.encodeEnd(context);
     activated = false;
   }
 
+  @Override
   public void encodeAjax(FacesContext facesContext) throws IOException {
     super.encodeAjax(facesContext);
     activated = false;
   }
 
-  public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+  @Override
+  public boolean invokeOnComponent(FacesContext facesContext, String clientId, ContextCallback callback)
       throws FacesException {
-    return FacesUtils.invokeOnComponent(context, this, clientId, callback);
+    return FacesUtils.invokeOnComponent(facesContext, this, clientId, callback);
   }
 
   public LayoutManager getLayoutManager() {
     return (LayoutManager) getFacet(Facets.LAYOUT);
   }
-  
+
   public void setLayoutManager(LayoutManager layoutManager) {
     getFacets().put(Facets.LAYOUT, (UILayoutBase) layoutManager);
   }
-  
+
   public abstract Measure getWidth();
 
   public abstract void setWidth(Measure width);
@@ -187,4 +206,6 @@ public abstract class AbstractUIPopup ex
   public abstract Measure getLeft();
 
   public abstract void setLeft(Measure left);
+
+  public abstract void setZIndex(Integer zIndex);
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java?rev=927581&r1=927580&r2=927581&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/css/Style.java Thu Mar 25 20:18:47 2010
@@ -41,6 +41,7 @@ public class Style implements Serializab
   private Measure paddingTop;
   private Measure paddingBottom;
   private String backgroundImage;
+  private Integer zIndex;
 
   public Style() {
   }
@@ -57,6 +58,7 @@ public class Style implements Serializab
     this.paddingTop = map.paddingTop;
     this.paddingBottom = map.paddingBottom;
     this.backgroundImage = map.backgroundImage;
+    this.zIndex = map.zIndex;
   }
 
   public Style(FacesContext facesContext, LayoutBase layout) {
@@ -158,6 +160,11 @@ public class Style implements Serializab
       buf.append(backgroundImage);
       buf.append(';');
     }
+    if (zIndex != null) {
+      buf.append("z-index:");
+      buf.append(zIndex);
+      buf.append(';');
+    }
 
     return buf.toString();
   }
@@ -249,4 +256,12 @@ public class Style implements Serializab
   public void setBackgroundImage(String backgroundImage) {
     this.backgroundImage = backgroundImage;
   }
+
+  public Integer getZIndex() {
+    return zIndex;
+  }
+
+  public void setZIndex(Integer zIndex) {
+    this.zIndex = zIndex;
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupTagDeclaration.java?rev=927581&r1=927580&r2=927581&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupTagDeclaration.java Thu Mar 25 20:18:47 2010
@@ -22,11 +22,7 @@ import org.apache.myfaces.tobago.apt.ann
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.taglib.decl.HasId;
-import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
-import org.apache.myfaces.tobago.taglib.decl.IsGridLayoutComponentWithDeprecatedDimension;
-import org.apache.myfaces.tobago.taglib.decl.IsGridLayoutContainer;
-import org.apache.myfaces.tobago.taglib.decl.IsRendered;
+import org.apache.myfaces.tobago.taglib.decl.*;
 
 /**
  * Renders a popup panel.
@@ -61,5 +57,13 @@ public interface PopupTagDeclaration 
   @TagAttribute
   @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure")
   void setTop(String top);
-  
+
+  /**
+   * Represents the visibility order of the popup. The renderer may implemented this visibility by the CSS z-index.
+   *
+   * @param zIndex The visibility order.
+   */
+  @UIComponentTagAttribute(type = "java.lang.Integer")
+  void setZIndex(String zIndex);
+
 }