You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/11/26 19:55:07 UTC

svn commit: r598384 - in /myfaces/tobago/trunk/theme/scarborough/src/main: java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/

Author: bommel
Date: Mon Nov 26 10:55:07 2007
New Revision: 598384

URL: http://svn.apache.org/viewvc?rev=598384&view=rev
Log:
(TOBAGO-553) Support for click and dblClick action in the sheet

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago-sheet.css

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=598384&r1=598383&r2=598384&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Mon Nov 26 10:55:07 2007
@@ -131,8 +131,26 @@
     writer.writeIdAttribute(sheetId + "_outer_div");
     writer.writeClassAttribute("tobago-sheet-outer-div");
     writer.writeStyleAttribute(sheetStyle);
+    UICommand clickAction = null;
+    UICommand dblClickAction = null;
+    for (UIComponent child : (List<UIComponent>) data.getChildren()) {
+      if (child instanceof UIColumnEvent) {
+        UIColumnEvent columnEvent = (UIColumnEvent) child;
+        UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
+        if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
+          UICommand action = (UICommand) selectionChild;
+          if ("click".equals(columnEvent.getEvent())) {
+            clickAction = action;
+          }
+          if ("dblclick".equals(columnEvent.getEvent())) {
+            dblClickAction = action;
+          }
+        }
+      }
+    }
+
 
-    renderSheet(facesContext, data);
+    renderSheet(facesContext, data, (clickAction != null || dblClickAction != null));
 
     writer.endElement(HtmlConstants.DIV);
 
@@ -152,23 +170,6 @@
       UIReload update = (UIReload) facetReload;
       frequency = update.getFrequency();
     }
-    UICommand clickAction = null;
-    UICommand dblClickAction = null;
-    for (UIComponent child : (List<UIComponent>) data.getChildren()) {
-      if (child instanceof UIColumnEvent) {
-        UIColumnEvent columnEvent = (UIColumnEvent) child;
-        UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
-        if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
-          UICommand action = (UICommand) selectionChild;
-          if ("click".equals(columnEvent.getEvent())) {
-            clickAction = action;
-          }
-          if ("dblclick".equals(columnEvent.getEvent())) {
-            dblClickAction = action;
-          }
-        }
-      }
-    }
     final String[] cmds = {
         "new Tobago.Sheet(\"" + sheetId + "\", " + ajaxEnabled
             + ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable() + "\", "+ frequency
@@ -190,7 +191,7 @@
     }
   }
 
-  private void renderSheet(FacesContext facesContext, UIData data) throws IOException {
+  private void renderSheet(FacesContext facesContext, UIData data, boolean hasClickAction) throws IOException {
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
     ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
     UIViewRoot viewRoot = facesContext.getViewRoot();
@@ -371,6 +372,9 @@
         if (columnIndex == 0) {
           tdClass.addClass("sheet", "cell-first-column"); // XXX not a standard compliant name
         }
+        if (hasClickAction) {
+          tdClass.addClass("sheet", "cell-clickable");
+        }
         StyleClasses cellClass = StyleClasses.ensureStyleClasses(column);
         tdClass.addClasses(cellClass);
 
@@ -1102,7 +1106,25 @@
       }
     }
     if (update) {
-      renderSheet(facesContext, (UIData) component);
+      // TODO find a better way
+      UICommand clickAction = null;
+      UICommand dblClickAction = null;
+      for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+        if (child instanceof UIColumnEvent) {
+          UIColumnEvent columnEvent = (UIColumnEvent) child;
+          UIComponent selectionChild = (UIComponent) child.getChildren().get(0);
+          if (selectionChild != null && selectionChild instanceof UICommand && selectionChild.isRendered()) {
+            UICommand action = (UICommand) selectionChild;
+            if ("click".equals(columnEvent.getEvent())) {
+              clickAction = action;
+            }
+            if ("dblclick".equals(columnEvent.getEvent())) {
+              dblClickAction = action;
+            }
+          }
+        }
+      }
+      renderSheet(facesContext, (UIData) component, (clickAction != null || dblClickAction != null));
     } else {
       facesContext.getResponseWriter().write(AjaxResponseRenderer.CODE_NOT_MODIFIED);
     }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago-sheet.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago-sheet.css?rev=598384&r1=598383&r2=598384&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago-sheet.css (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/tobago-sheet.css Mon Nov 26 10:55:07 2007
@@ -121,6 +121,10 @@
   vertical-align: top;
 }
 
+.tobago-sheet-cell-clickable {
+   cursor: pointer;
+}
+
 .tobago-sheet-cell-outer {
   overflow: hidden;
 }