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 2011/06/30 00:02:40 UTC
svn commit: r1141266 - in /myfaces/tobago/branches/tobago-1.0.x/theme:
scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/s...
Author: lofwyr
Date: Wed Jun 29 22:02:39 2011
New Revision: 1141266
URL: http://svn.apache.org/viewvc?rev=1141266&view=rev
Log:
TOBAGO-1008: Impossible to select a row in tc:sheet by keyboard
- patch applied
- minor cleanup
Modified:
myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1141266&r1=1141265&r2=1141266&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Wed Jun 29 22:02:39 2011
@@ -157,12 +157,6 @@ public class SheetRenderer extends Layou
writer.endElement(HtmlConstants.DIV);
- ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
- UIViewRoot viewRoot = facesContext.getViewRoot();
- String contextPath = facesContext.getExternalContext().getRequestContextPath();
-
- String unchecked = contextPath + resourceManager.getImage(viewRoot, "image/sheetUnchecked.gif");
- String checked = contextPath + resourceManager.getImage(viewRoot, "image/sheetChecked.gif");
boolean ajaxEnabled = TobagoConfig.getInstance(facesContext).isAjaxEnabled();
final String[] styles = new String[]{"style/tobago-sheet.css"};
@@ -175,7 +169,7 @@ public class SheetRenderer extends Layou
}
final String[] cmds = {
"new Tobago.Sheet(\"" + sheetId + "\", " + ajaxEnabled
- + ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable()
+ + ", undefined, undefined, \"" + data.getSelectable()
+ "\", " + columnSelectorIndex + ", "+ frequency
+ ", " + (clickAction!=null?HtmlRendererUtil.getJavascriptString(clickAction.getId()):null)
+ ", " + HtmlRendererUtil.getRenderedPartiallyJavascriptArray(facesContext, clickAction)
@@ -428,17 +422,13 @@ public class SheetRenderer extends Layou
writer.flush();
if (column instanceof UIColumnSelector) {
- final boolean disabled
- = ComponentUtil.getBooleanAttribute(column, ATTR_DISABLED);
- writer.startElement(HtmlConstants.IMG, null);
- if (disabled) {
- writer.writeAttribute(HtmlAttributes.SRC, selectorDisabled, false);
- } else {
- writer.writeAttribute(HtmlAttributes.SRC, unchecked, false);
- }
+ final boolean disabled = ComponentUtil.getBooleanAttribute(column, ATTR_DISABLED);
+ writer.startElement(HtmlConstants.INPUT, null);
+ writer.writeAttribute(HtmlAttributes.TYPE, "checkbox", false);
+ writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
writer.writeIdAttribute(sheetId + "_data_row_selector_" + rowIndex);
- writer.writeClassAttribute("tobago-sheet-column-selector");
- writer.endElement(HtmlConstants.IMG);
+ writer.writeClassAttribute("tobago-selectBooleanCheckbox-default");
+ writer.endElement(HtmlConstants.INPUT);
} else {
List<UIComponent> childs = data.getRenderedChildrenOf(column);
for (UIComponent grandkid : childs) {
Modified: myfaces/tobago/branches/tobago-1.0.x/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/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1141266&r1=1141265&r2=1141266&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Jun 29 22:02:39 2011
@@ -46,8 +46,6 @@ Tobago.Sheet = function(sheetId, enableA
this.id = sheetId;
Tobago.Sheets.put(this);
this.ajaxEnabled = enableAjax;
- this.checkedImage = checkedImage;
- this.uncheckedImage = uncheckedImage;
this.selectable = selectable;
this.columnSelectorIndex = columnSelectorIndex;
this.autoReload = autoReload;
@@ -70,6 +68,9 @@ Tobago.Sheet = function(sheetId, enableA
this.headerWidthsId = this.id + Tobago.SUB_COMPONENT_SEP + "widths";
this.scrollPositionId = this.id + Tobago.SUB_COMPONENT_SEP + "scrollPosition";
+ this.mouseDownX = undefined;
+ this.mouseDownY = undefined;
+
if (this.ajaxEnabled) {
Tobago.ajaxComponents[this.id] = this;
// option are only used for ajax request
@@ -461,6 +462,7 @@ Tobago.Sheet.prototype.addSelectionListe
var i = 0;
while (row) {
Tobago.addBindEventListener(row, "mousedown", this, "doMouseDownSelect");
+ Tobago.addBindEventListener(row, "mouseup", this, "doMouseUpSelect");
Tobago.addBindEventListener(row, "click", this, "doSelection");
if (this.dblClickActionId) {
Tobago.addBindEventListener(row, "dblclick", this, "doDblClick");
@@ -479,6 +481,14 @@ Tobago.Sheet.prototype.doMouseDownSelect
this.mouseDownY = event.clientY;
};
+Tobago.Sheet.prototype.doMouseUpSelect = function(event) {
+ if (!event) {
+ event = window.event;
+ }
+ this.mouseDownX = undefined;
+ this.mouseDownY = undefined;
+};
+
Tobago.Sheet.prototype.doSelection = function(event) {
if (! event) {
event = window.event;
@@ -499,9 +509,10 @@ Tobago.Sheet.prototype.doSelection = fun
//LOG.debug("srcElement = " + srcElement.tagName);
//LOG.debug("Actionid " + this.clickActionId);
//LOG.debug("ID " + this.id);
- if (! Tobago.isInputElement(srcElement.tagName)) {
+ if (srcElement.id.search(/_data_row_selector_/) > -1 || !Tobago.isInputElement(srcElement.tagName)) {
- if (Math.abs(this.mouseDownX - event.clientX) + Math.abs(this.mouseDownY - event.clientY) > 5) {
+ if (this.mouseDownX != undefined &&
+ Math.abs(this.mouseDownX - event.clientX) + Math.abs(this.mouseDownY - event.clientY) > 5) {
// The user has moved the mouse. We assume, the user want to select some text inside the sheet,
// so we doesn't select the row.
return;
@@ -622,28 +633,47 @@ Tobago.Sheet.prototype.updateSelectionVi
var rowIndex = i + this.firstRowIndex * 1; // * 1 to keep integer operation
var re = new RegExp("," + rowIndex + ",");
var classes = row.className;
- var image = this.getSelectionElementForRow(row);
+ var checkbox = this.getSelectionElementForRow(row);
if (selected.search(re) == -1) { // not selected: remove selection class
Tobago.removeCssClass(row, "tobago-sheet-row-selected");
+ this.setLinkSelected(i - this.firstRowIndex, false);
- if (image && image.src && !image.src.match(/Disabled/)) {
- image.src = this.uncheckedImage;
+ if (checkbox) {
+ checkbox.checked = false;
}
} else { // selected: check selection class
if (classes.search(/tobago-sheet-row-selected/) == -1) {
Tobago.addCssClass(row, "tobago-sheet-row-selected");
+ this.setLinkSelected(i - this.firstRowIndex, true);
}
- if (image && image.src && !image.src.match(/Disabled/)) {
- image.src = this.checkedImage;
+ if (checkbox) {
+ checkbox.checked = true;
}
}
row = this.getSiblingRow(row, ++i);
}
};
+Tobago.Sheet.prototype.setLinkSelected = function(rowIndex, selected) {
+ var j = 0;
+ var idPrefix = this.id + "_data_row_" + rowIndex + "_column";
+ var column = Tobago.element(idPrefix + j++);
+ while (column) {
+ var content = column.childNodes[0].childNodes[0];
+ if (content != null && content.tagName == "A") {
+ if (selected == true) {
+ Tobago.addCssClass(content, "tobago-sheet-row-selected");
+ } else {
+ Tobago.removeCssClass(content, "tobago-sheet-row-selected");
+ }
+ }
+ column = Tobago.element(idPrefix + j++);
+ }
+};
+
Tobago.Sheet.prototype.toggleSelectionForRow = function(dataRow) {
var rowIndex = dataRow.id.substring(dataRow.id.lastIndexOf("_data_tr_") + 9);
this.toggleSelection(rowIndex);
@@ -850,6 +880,12 @@ Tobago.Sheet.prototype.endResize = funct
var cell = Tobago.element(idPrefix + i++ + idPostfix);
while (cell) {
cell.style.width = this.newWidth + "px";
+
+ var content = cell.childNodes[0].childNodes[0];
+ if (content != null) {
+ content.style.width = (this.newWidth - 4) + "px";
+ }
+
cell = Tobago.element(idPrefix + i++ + idPostfix);
}