myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r432744 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ example/demo/src/main/webapp/overview/ theme/scarborough/src/main/java/org/apache/myf...
Date Fri, 18 Aug 2006 22:10:36 GMT
Author: weber
Date: Fri Aug 18 15:10:35 2006
New Revision: 432744

URL: http://svn.apache.org/viewvc?rev=432744&view=rev
Log:
TOBAGO-116 (selectable modes in sheet)

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTag.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTagDeclaration.java
    myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIData.java?rev=432744&r1=432743&r2=432744&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIData.java
Fri Aug 18 15:10:35 2006
@@ -22,6 +22,7 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_INNER_WIDTH;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_WIDTH;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_LIST_STRING;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_HEADER;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH_LIST_STRING;
@@ -71,7 +72,10 @@
   public static final String SORTER_ID = "sorter";
 
   public static final String NONE = "none";
+  public static final String SINGLE = "single";
+  public static final String MULTI = "multi";
   public static final int DEFAULT_DIRECT_LINK_COUNT = 9;
+  private static final String DEFAULT_SELECTABLE = MULTI;
 
   private MethodBinding stateChangeListener;
   private List<Integer> widthList;
@@ -83,6 +87,8 @@
   private String showDirectLinks;
   private Integer directLinkCount;
 
+  private String selectable;
+
   public void encodeBegin(FacesContext facesContext) throws IOException {
     UILayout.prepareDimension(facesContext, this);
     SheetState state = getSheetState(facesContext);
@@ -151,6 +157,22 @@
     this.showDirectLinks = showDirectLinks;
   }
 
+  public String getSelectable() {
+    if (selectable != null) {
+      return selectable;
+    }
+    ValueBinding vb = getValueBinding(ATTR_SELECTABLE);
+    if (vb != null) {
+      return (String) vb.getValue(getFacesContext());
+    } else {
+      return DEFAULT_SELECTABLE;
+    }
+  }
+
+  public void setSelectable(String selectable) {
+    this.selectable = selectable;
+  }
+
   public Integer getDirectLinkCount() {
     if (directLinkCount != null) {
       return directLinkCount;
@@ -437,7 +459,7 @@
 
 
   public Object saveState(FacesContext context) {
-    Object[] saveState = new Object[9];
+    Object[] saveState = new Object[10];
     saveState[0] = super.saveState(context);
     saveState[1] = sheetState;
     saveState[2] = saveAttachedState(context, sortActionListener);
@@ -447,6 +469,7 @@
     saveState[6] = showPageRange;
     saveState[7] = showDirectLinks;
     saveState[8] = directLinkCount;
+    saveState[9] = selectable;
     return saveState;
   }
 
@@ -461,6 +484,7 @@
     showPageRange = (String) values[6];
     showDirectLinks = (String) values[7];
     directLinkCount = (Integer) values[8];
+    selectable = (String) values[9];
   }
 
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTag.java?rev=432744&r1=432743&r2=432744&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTag.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTag.java
Fri Aug 18 15:10:35 2006
@@ -22,6 +22,7 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FORCE_VERTICAL_SCROLLBAR;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ROWS;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DIRECT_LINKS;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_HEADER;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_PAGE_RANGE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROW_RANGE;
@@ -50,6 +51,7 @@
   private String state;
   private String stateChangeListener;
   private String sortActionListener;
+  private String selectable;
 
   public String getComponentType() {
     // TODO: implement uidata with overridden processUpdates to store state
@@ -72,6 +74,7 @@
     state = null;
     stateChangeListener = null;
     sortActionListener = null;
+    selectable = null;
   }
 
   protected void setProperties(UIComponent component) {
@@ -91,6 +94,7 @@
     ComponentUtil.setValueBinding(component, ATTR_STATE, state);
     ComponentUtil.setStateChangeListener(data, stateChangeListener);
     ComponentUtil.setSortActionListener(data, sortActionListener);
+    ComponentUtil.setStringProperty(data, ATTR_SELECTABLE, selectable);
   }
 
   public String getColumns() {
@@ -185,5 +189,8 @@
     this.sortActionListener = sortActionListener;
   }
 
+  public void setSelectable(String selectable) {
+    this.selectable = selectable;
+  }
 }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTagDeclaration.java?rev=432744&r1=432743&r2=432744&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/SheetTagDeclaration.java
Fri Aug 18 15:10:35 2006
@@ -23,6 +23,7 @@
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
+import org.apache.myfaces.tobago.component.UIData;
 
 /*
  * Created by IntelliJ IDEA.
@@ -168,6 +169,17 @@
   @UIComponentTagAttribute(defaultValue = "none",
       allowedValues = {"left", "center", "right", "none"})
   void setShowRowRange(String showRowRange);
+
+  /**
+   * Flag indicating whether or not the sheet should be selectable <br />
+   * Valid values are <strong>none</strong>, <strong>single</strong>,
+   * and <strong>multi</strong>.<br/>
+   * The <strong>default</strong> is <code>multi</code>.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(defaultValue = UIData.MULTI,
+      allowedValues = {UIData.NONE, UIData.SINGLE, UIData.MULTI})
+  void setSelectable(String selectable);
 
   /**
    * Sheet state saving object.

Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp?rev=432744&r1=432743&r2=432744&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheetControl.jsp Fri Aug 18
15:10:35 2006
@@ -117,7 +117,8 @@
             rows="#{overviewController.sheetConfig.sheetRows}"
             directLinkCount="#{overviewController.sheetConfig.sheetDirectLinkCount}"
             stateChangeListener="#{demo.stateChangeListener}"
-            sortActionListener="#{overviewController.sheetSorter}" >
+            sortActionListener="#{overviewController.sheetSorter}"
+            selectable="multi">
           <f:facet name="reload">
             <tc:reload frequency="5000" />  
           </f:facet>

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=432744&r1=432743&r2=432744&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
Fri Aug 18 15:10:35 2006
@@ -21,6 +21,7 @@
  * $Id$
  */
 
+import static org.apache.myfaces.tobago.component.UIData.NONE;
 import static org.apache.myfaces.tobago.TobagoConstants.*;
 import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
 import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
@@ -117,7 +118,7 @@
     }
     final String[] cmds = {
         "new Tobago.Sheet(\"" + sheetId + "\", " + ajaxEnabled
-            + ", \"" + checked + "\", \"" + unchecked + "\", "+ frequency + ");"
+            + ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable() +
"\", "+ frequency + ");"
     };
 
     ComponentUtil.addStyles(data, styles);
@@ -169,6 +170,7 @@
     String bodyStyle = (String) attributes.get(ATTR_STYLE_BODY);
     int footerHeight = (Integer) attributes.get(ATTR_FOOTER_HEIGHT);
 
+    String selectable = data.getSelectable();
 
     Application application = facesContext.getApplication();
     SheetState state = data.getSheetState(facesContext);
@@ -185,12 +187,14 @@
     writer.writeAttribute("value", "", null);
     writer.endElement("input");
 
-    writer.startElement("input", null);
-    writer.writeIdAttribute(sheetId + SELECTED_POSTFIX);
-    writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
-    writer.writeAttribute("type", "hidden", null);
-    writer.writeAttribute("value", selectedRows, null);
-    writer.endElement("input");
+    if (!NONE.equals(selectable)) {
+      writer.startElement("input", null);
+      writer.writeIdAttribute(sheetId + SELECTED_POSTFIX);
+      writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
+      writer.writeAttribute("type", "hidden", null);
+      writer.writeAttribute("value", selectedRows, null);
+      writer.endElement("input");
+    }
 
 
     final boolean showHeader = data.isShowHeader();

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=432744&r1=432743&r2=432744&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
(original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Fri Aug 18 15:10:35 2006
@@ -39,12 +39,13 @@
 
 };
 
-Tobago.Sheet = function(sheetId, enableAjax, checkedImage, uncheckedImage, autoReload) {
+Tobago.Sheet = function(sheetId, enableAjax, checkedImage, uncheckedImage, selectable, autoReload)
{
   this.startTime = new Date();
   this.id = sheetId;
   this.ajaxEnabled = enableAjax;
   this.checkedImage = checkedImage;
   this.uncheckedImage = uncheckedImage;
+  this.selectable = selectable;
   this.autoReload = autoReload;
 
   this.resizerId = undefined;
@@ -350,9 +351,12 @@
     if (this.firstRowId) {
       this.tobagoLastClickedRowId = this.firstRowIndex;
     }
-    this.addSelectionListener();
     this.adjustScrollBars();
-    this.updateSelectionView();
+
+    if (this.selectable && (this.selectable == "single" || this.selectable == "multi"))
{
+      this.addSelectionListener();
+      this.updateSelectionView();
+    }
 
     if (this.ajaxEnabled) {
       this.setupSortHeaders();
@@ -437,12 +441,12 @@
       var rowIndex = rowId.substring(rowId.lastIndexOf("_data_tr_") + 9);
       var selector = Tobago.element(this.id + "_data_row_selector_" + rowIndex);
 
-      if (! event.ctrlKey && ! selector) {
+      if ((!event.ctrlKey && !selector) || this.selectable == "single" ) {
         // clearAllSelections();
         Tobago.element(this.selectedId).value = "";
       }
 
-      if (event.shiftKey) {
+      if (event.shiftKey && this.selectable == "multi") {
         this.selectRange(dataRow);
       }
       else {



Mime
View raw message