JBoss Rich Faces SVN: r1057 - in trunk/docs/userguide/en: src and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-06 13:01:02 -0400 (Wed, 06 Jun 2007)
New Revision: 1057
Added:
trunk/docs/userguide/en/src/
trunk/docs/userguide/en/src/main/
trunk/docs/userguide/en/src/main/docbook/
trunk/docs/userguide/en/src/main/resources/
Log:
reorganize projects for a Maven documentation build
17 years, 7 months
JBoss Rich Faces SVN: r1056 - in trunk: sandbox/scrollable-grid/src/main/java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-06 13:00:43 -0400 (Wed, 06 Jun 2007)
New Revision: 1056
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/HTMLEncodingContributor.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java
trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
added selection renderer contributor
Modified: trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-06-06 17:00:43 UTC (rev 1056)
@@ -52,11 +52,14 @@
</property>
- <property attachedstate="true">
+ <property attachedstate="true" hidden="true">
<name>sortOrder</name>
<classname>org.richfaces.model.SortOrder</classname>
</property>
-
+ <property attachedstate="true" hidden="true">
+ <name>selection</name>
+ <classname>org.richfaces.model.selection.Selection</classname>
+ </property>
&ui_component_attributes;
</component>
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selectable {
+ public Selection getSelection();
+ public void setSelection (Selection selection);
+}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -41,7 +41,7 @@
*
*/
-public abstract class UIScrollableGrid extends UIRepeat implements AjaxComponent, Sortable{
+public abstract class UIScrollableGrid extends UIRepeat implements AjaxComponent, Sortable, Selectable{
private transient Collection partialUpdateChildren;
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -3,12 +3,11 @@
*/
package org.richfaces.model;
-import java.io.Serializable;
/**
* @author Maksim Kaszynski
*
*/
public interface Entity {
- public Serializable getId();
+ public Object getId();
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -4,7 +4,6 @@
package org.richfaces.model;
import java.io.IOException;
-import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -25,10 +24,8 @@
private static final Log log = LogFactory.getLog(GridDataModel.class);
- private Serializable rowKey;
+ private Object rowKey;
- private int rowIndex = Integer.MIN_VALUE;
-
private Map mapping;
public Object getRowKey() {
@@ -36,7 +33,7 @@
}
public void setRowKey(Object key) {
- rowKey = (Serializable) key;
+ rowKey = key;
}
public void walk(FacesContext context, DataVisitor visitor, Range range,
@@ -78,9 +75,9 @@
public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
- public abstract Object getObjectById(Serializable id);
+ public abstract Object getObjectById(Object id);
- private Object loadAndMap(Serializable id) {
+ private Object loadAndMap(Object id) {
if (log.isTraceEnabled()) {
log.trace("loadAndMap " + id);
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -16,5 +16,5 @@
public int size();
- public boolean isSelected(Serializable rowKey);
+ public boolean isSelected(Object rowKey);
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -18,11 +18,11 @@
private Set keys = new HashSet();
- public boolean addKey(Serializable rowKey) {
+ public boolean addKey(Object rowKey) {
return keys.add(rowKey);
}
- public boolean removeKey(Serializable rowKey) {
+ public boolean removeKey(Object rowKey) {
return keys.remove(rowKey);
}
@@ -34,7 +34,7 @@
return keys.size();
}
- public boolean isSelected(Serializable rowKey) {
+ public boolean isSelected(Object rowKey) {
return keys.contains(rowKey);
}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/HTMLEncodingContributor.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/HTMLEncodingContributor.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/HTMLEncodingContributor.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -0,0 +1,11 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public interface HTMLEncodingContributor {
+ public void encode(FacesContext context, UIComponent component)
+ throws IOException;
+}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -1,17 +1,14 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
-import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
@@ -28,10 +25,8 @@
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.component.UIScrollableGridColumn;
import org.richfaces.event.sort.SortEvent;
-import org.richfaces.model.selection.ClientSelection;
-import org.richfaces.model.selection.Selection;
-import org.richfaces.model.selection.SimpleSelection;
import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.RendererContributor;
import org.richfaces.renderkit.html.response.GridScrollSettings;
import org.richfaces.utils.TemplateLoader;
@@ -60,8 +55,6 @@
private RendererBase footerCellTemplate = null;
- private static final String CLIENT_SELECTION = "clientSelection";
-
private final Log log = LogFactory.getLog(ScrollableGridBaseRenderer.class);
private final ColumnVisitor columnsWidthCounter = new ColumnVisitor(){
@@ -245,11 +238,11 @@
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
String row_id = null;
-
+ /*
System.out.println("row data index: " + grid.getRowIndex());
System.out.println("rows count " + grid.getRows());
System.out.println("local rows " + state.getRowIndex());
-
+ */
for (Iterator iter = grid.getChildren().iterator(); iter.hasNext(); ) {
UIComponent kid = (UIComponent) iter.next();
@@ -301,7 +294,6 @@
}
};
-
public String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
return "Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]", "_");
@@ -497,126 +489,6 @@
}
- private void decodeSelection(FacesContext context, UIScrollableGrid grid)
- throws IOException{
-
- String clientId = grid.getClientId(context);
- String id = clientId + "_selection";
- ExternalContext externalContext = context.getExternalContext();
- Map requestParamMap = externalContext.getRequestParameterMap();
- Application application = context.getApplication();
-
- String value = (String) requestParamMap.get(id);
-
- Converter converter = application.createConverter(ClientSelection.class);
-
- ClientSelection _oldClientSelection =
- (ClientSelection) grid.getAttributes().get(CLIENT_SELECTION);
-
- final ClientSelection oldClientSelection =
- _oldClientSelection == null ?
- new ClientSelection() :
- _oldClientSelection;
-
- final ClientSelection clientSelection =
- (ClientSelection) converter.getAsObject(context, grid, value);
-
-
-
- //FIXME: Obscure code. Hope Anton will make it more clear
- final GridRendererState state = GridRendererState.createState(context, grid);
-
- final SimpleSelection simpleSelection = new SimpleSelection();
-
- grid.walk(context,
- new DataVisitor() {
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- int i = state.getRowIndex();
-
- if (shouldAddToSelection(i, oldClientSelection, clientSelection)) {
-
- simpleSelection.addKey((Serializable)rowKey);
-
- } else if (shouldRemoveFromSelection(i, oldClientSelection, clientSelection)){
-
- simpleSelection.removeKey((Serializable) rowKey);
-
- }
-
- }
- },
- state);
-
-
- GridRendererState.restoreState(context);
-
- //FIXME:
-
-
- }
-
- //Decide whether to add new row to selection based on comparison with old one
- private boolean shouldAddToSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
- return false;
- }
-
- //Decide whether to remove new row to selection based on comparison with old one
- private boolean shouldRemoveFromSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
- return false;
- }
-
-
- private void encodeSelection(FacesContext context, UIScrollableGrid grid) throws IOException {
- final GridRendererState state = GridRendererState.createState(context, grid);
-
- final Selection gridSelection = new SimpleSelection();
- final ClientSelection clientSelection = new ClientSelection();
-
- grid.walk(context,
- new DataVisitor() {
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- if (gridSelection.isSelected((Serializable) rowKey)) {
-
- int i = state.getRowIndex();
-
- clientSelection.addIndex(i);
- }
-
-
-
-
- }
- },
- state);
-
-
- GridRendererState.restoreState(context);
-
- grid.getAttributes().put(CLIENT_SELECTION, clientSelection);
- }
-
- public void writeSelection(FacesContext context, UIScrollableGrid grid)
- throws IOException {
-
- Application application = context.getApplication();
-
- Converter converter =
- application.createConverter(ClientSelection.class);
-
- String string =
- converter.getAsString(context, grid, grid.getAttributes().get(CLIENT_SELECTION));
-
- if (string == null) {
- string = "";
- }
-
- }
-
-
private void decodeScrolling(String submitedState, UIScrollableGrid grid){
boolean isEmpty = true;
@@ -681,7 +553,7 @@
private GridScrollSettings createOptions(UIScrollableGrid grid){
- int index = grid.getRowIndex();
+ int index = grid.getFirst();
int startRow = ((Integer)grid.getAttributes().get(CLIENT_ROW_KEY)).intValue();
int count = grid.getRows();
@@ -760,4 +632,18 @@
return footerCellTemplate;
}
+ public void contributorsEncodeHere(FacesContext context, UIScrollableGrid grid) throws IOException {
+ RendererContributor [] contribs = getContributors();
+
+ if (contribs != null) {
+ for (int i = 0; i < contribs.length; i++) {
+ RendererContributor rendererContributor = contribs[i];
+
+ if (rendererContributor instanceof HTMLEncodingContributor) {
+ ((HTMLEncodingContributor) rendererContributor).encode(context, grid);
+ }
+ }
+ }
+ }
+
}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -0,0 +1,236 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.model.selection.ClientSelection;
+import org.richfaces.model.selection.Selection;
+import org.richfaces.model.selection.SimpleSelection;
+import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.RendererContributor;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectionRendererContributor implements RendererContributor {
+
+
+ public static final String CLIENT_SELECTION = "clientSelection";
+
+ public static final String getSelectionInputName(FacesContext context,
+ UIScrollableGrid grid) {
+ String id = grid.getBaseClientId(context) + "_sel";
+
+ return id;
+ }
+
+ public void decode(FacesContext context, UIComponent component,
+ CompositeRenderer compositeRenderer) {
+
+ UIScrollableGrid grid = (UIScrollableGrid) component;
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestParamMap = externalContext.getRequestParameterMap();
+ Application application = context.getApplication();
+
+ String id = getSelectionInputName(context, grid);
+
+ String value = (String) requestParamMap.get(id);
+
+ Converter converter = application.createConverter(ClientSelection.class);
+
+ ClientSelection _oldClientSelection =
+ (ClientSelection) grid.getAttributes().get(CLIENT_SELECTION);
+
+ final ClientSelection oldClientSelection =
+ _oldClientSelection == null ?
+ new ClientSelection() :
+ _oldClientSelection;
+
+ final ClientSelection clientSelection =
+ (ClientSelection) converter.getAsObject(context, grid, value);
+
+
+
+ final GridRendererState state =
+ GridRendererState.createState(context, grid);
+
+ final SimpleSelection simpleSelection = new SimpleSelection();
+
+ try {
+ grid.walk(context,
+ new DataVisitor() {
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ int i = state.getRowIndex();
+
+ if (shouldAddToSelection(i, oldClientSelection, clientSelection)) {
+
+ simpleSelection.addKey(rowKey);
+
+ } else if (shouldRemoveFromSelection(i, oldClientSelection, clientSelection)){
+
+ simpleSelection.removeKey(rowKey);
+
+ }
+
+ }
+ },
+ state);
+ } catch(IOException e) {
+ throw new FacesException(e);
+ }
+
+
+ GridRendererState.restoreState(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.renderkit.RendererContributor#getAcceptableClass()
+ */
+ public Class getAcceptableClass() {
+ return UIScrollableGrid.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.renderkit.RendererContributor#getScriptContribution(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public String getScriptContribution(FacesContext context,
+ UIComponent component) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.renderkit.RendererContributor#getScriptDependencies()
+ */
+ public String[] getScriptDependencies() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.renderkit.RendererContributor#getStyleDependencies()
+ */
+ public String[] getStyleDependencies() {
+ return null;
+ }
+
+ public ScriptOptions buildOptions(FacesContext context,
+ UIComponent component) {
+ ScriptOptions scriptOptions = new ScriptOptions(component);
+ scriptOptions.addOption("selectionInput", getSelectionInputName(
+ context, (UIScrollableGrid) component));
+ return null;
+ }
+
+ //Decide whether to add new row to selection based on comparison with old one
+ private boolean shouldAddToSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
+ return false;
+ }
+
+ //Decide whether to remove new row to selection based on comparison with old one
+ private boolean shouldRemoveFromSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
+ return false;
+ }
+
+
+ private void encodeSelection(FacesContext context, UIScrollableGrid grid) throws IOException {
+ final GridRendererState state = GridRendererState.createState(context, grid);
+
+ final Selection gridSelection = new SimpleSelection();
+ final ClientSelection clientSelection = new ClientSelection();
+
+ grid.walk(context,
+ new DataVisitor() {
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ if (gridSelection.isSelected(rowKey)) {
+
+ int i = state.getRowIndex();
+
+ clientSelection.addIndex(i);
+ }
+
+
+
+
+ }
+ },
+ state);
+
+
+ GridRendererState.restoreState(context);
+
+ grid.getAttributes().put(CLIENT_SELECTION, clientSelection);
+ }
+
+ /**
+ * Get client selection from the component, transform it into string form,
+ * and write it as hidden input
+ * @param context
+ * @param grid
+ * @throws IOException
+ */
+ public void writeSelection(FacesContext context, UIScrollableGrid grid)
+ throws IOException {
+
+ Application application = context.getApplication();
+
+ Converter converter =
+ application.createConverter(ClientSelection.class);
+
+ String string =
+ converter.getAsString(context, grid, grid.getAttributes().get(CLIENT_SELECTION));
+
+ if (string == null) {
+ string = "";
+ }
+
+ String id = grid.getBaseClientId(context) + "_s";
+
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.INPUT_ELEM, grid);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, id, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, string, null);
+ writer.endElement(HTML.INPUT_ELEM);
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+
+ if (ajaxContext.isAjaxRequest()) {
+ ajaxContext.addRenderedArea(id);
+ }
+
+ }
+
+
+}
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java 2007-06-06 16:32:32 UTC (rev 1055)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java 2007-06-06 17:00:43 UTC (rev 1056)
@@ -7,6 +7,7 @@
import java.util.List;
import org.richfaces.demo.datagrid.model.Channel;
+import org.richfaces.demo.datagrid.model.Issue;
import org.richfaces.model.GridDataModel;
import org.richfaces.model.SortOrder;
@@ -22,7 +23,7 @@
* @see org.richfaces.model.GridDataModel#getObjectById(java.io.Serializable)
*/
@Override
- public Object getObjectById(Serializable id) {
+ public Object getObjectById(Object id) {
return channel.findById((Integer) id);
}
@@ -30,7 +31,7 @@
* @see org.richfaces.model.GridDataModel#loadData(int, int, org.richfaces.model.SortOrder)
*/
@Override
- public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+ public List <Issue> loadData(int startRow, int endRow, SortOrder sortOrder) {
return channel.executeQuery(startRow, endRow, sortOrder);
}
17 years, 7 months
JBoss Rich Faces SVN: r1055 - trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-06-06 12:32:32 -0400 (Wed, 06 Jun 2007)
New Revision: 1055
Modified:
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
http://jira.jboss.com/jira/browse/RF-209
Modified: trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
--- trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-06-06 16:20:04 UTC (rev 1054)
+++ trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-06-06 16:32:32 UTC (rev 1055)
@@ -348,7 +348,12 @@
var item = entry;
var realOffset = 0;
while (item && (item != scroll)) {
- realOffset += item.offsetTop;
+ // Avoid bug in Safari. Details: http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in...
+ if ("SAFARI" == RichFaces.navigatorType() && "TR" == item.tagName) {
+ realOffset += document.getElementsByClassName("dr-sb-cell-padding", item)[0].offsetTop;
+ }
+ else
+ realOffset += item.offsetTop;
if (item.parentNode == scroll) break;
item = item.offsetParent;
}
@@ -356,8 +361,16 @@
LOG.debug("Scroll = " + scroll.scrollTop
+ " , reallOffset= " + realOffset
+ " scrollHeight= " + scroll.offsetHeight);
- if (realOffset > scroll.scrollTop + scroll.clientHeight - entry.offsetHeight) {
- scroll.scrollTop = realOffset - scroll.clientHeight + entry.offsetHeight;
+
+ var entryOffsetHeight;
+ if ("SAFARI" == RichFaces.navigatorType()) {
+ var tdElement = document.getElementsByClassName("dr-sb-cell-padding", item)[0];
+ entryOffsetHeight = tdElement.offsetTop + tdElement.offsetHeight;
+ } else
+ entryOffsetHeight = entry.offsetHeight;
+
+ if (realOffset > scroll.scrollTop + scroll.clientHeight - entryOffsetHeight) {
+ scroll.scrollTop = realOffset - scroll.clientHeight + entryOffsetHeight;
} else if (realOffset < scroll.scrollTop) {
scroll.scrollTop = realOffset;
}
17 years, 7 months
JBoss Rich Faces SVN: r1054 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-06-06 12:20:04 -0400 (Wed, 06 Jun 2007)
New Revision: 1054
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
Log:
fix ids for DOM elements.
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-06 15:03:07 UTC (rev 1053)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-06 16:20:04 UTC (rev 1054)
@@ -50,7 +50,7 @@
initialize: function(element, dataModel, templates) {
ClientUI.controls.grid.Grid.parentClass.constructor().call(this, element);
- if(!element || !element.id)
+ if(!this.element || !this.element.id)
this.element.id = "ClientUI_Grid" + ClientUI_controls_grid_Grid_idGenerator++;
this.dataModel = dataModel;
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06 15:03:07 UTC (rev 1053)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06 16:20:04 UTC (rev 1054)
@@ -721,12 +721,6 @@
return options;
},
_getRowIndex: function(rowId) {
- // prefix:row_2
- var index = -1;
- var match, pattern = /\:row_(\d*)/i;
- if (match = rowId.match(pattern)) {
- index = parseFloat(match[1]);
- }
- return index;
+ return Number(rowId.split(this.grid.getElement().id)[1].split(":")[2]);
}
});
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-06 15:03:07 UTC (rev 1053)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-06 16:20:04 UTC (rev 1054)
@@ -187,16 +187,16 @@
Object.extend(ClientUI.controls.grid.SelectionManager.prototype, {
initialize: function(gridElement) {
- this.rowPrefix = $("ClientUI_Box8").parentNode.id.split(":body:FrozenBox")[0];//gridElement.id;
+ this.rowPrefix = gridElement.id;
this.selection = new ClientUI.controls.grid.Selection();
// this.restoreState();
this.eventKeyPress = this.processKeyDown.bindAsEventListener(this);
Event.observe(document, "keypress", this.eventKeyPress);
- var frows = $("ClientUI_Box8").rows;
- var nrows = $("ClientUI_Box9").rows;
+ var frows = $(this.rowPrefix + ":f").rows;
+ var nrows = $(this.rowPrefix + ":n").rows;
var rowIndex;
for(var i = 0; i < frows.length; i++) {
- rowIndex = Number(frows[i].id.split("_")[2]);
+ rowIndex = Number(frows[i].id.split(this.rowPrefix)[1].split(":")[2]);
this.addListener(frows[i], rowIndex);
this.addListener(nrows[i], rowIndex);
}
@@ -316,7 +316,7 @@
break;
case 65: case 97: // Ctrl-A
if (this.inFocus && event.ctrlKey) {
- range = [0, $("ClientUI_Box8").rows.length];
+ range = [0, $(this.rowPrefix + ":f").rows.length];
this.setSelection(range);
noDefault = true;
}
@@ -384,7 +384,7 @@
for (; i <= range[1]; i++) {
this.addRowToSelection(i);
}
- for (; i < $("ClientUI_Box8").rows.length; i++) {
+ for (; i < $(this.rowPrefix + ":f").rows.length; i++) {
this.removeRowFromSelection(i);
}
},
@@ -397,16 +397,16 @@
addRowToSelection: function(rowIndex) {
this.selection.addId(rowIndex);
- var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ var fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.backgroundColor = "#DDDDFF";
nElement.style.backgroundColor = "#DDDDFF";
},
removeRowFromSelection: function(rowIndex) {
this.selection.removeId(rowIndex);
- var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ var fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.backgroundColor = "#FFFFFF";
nElement.style.backgroundColor = "#FFFFFF";
},
@@ -414,13 +414,13 @@
setActiveRow: function(rowIndex) {
var fElement, nElement;
if(this.activeRow) {
- fElement = $(this.rowPrefix + ":f:row_" + this.activeRow);
- nElement = $(this.rowPrefix + ":n:row_" + this.activeRow);
+ fElement = $(this.rowPrefix + ":f:" + this.activeRow);
+ nElement = $(this.rowPrefix + ":n:" + this.activeRow);
fElement.style.color = "#000000";
nElement.style.color = "#000000";
}
- fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.color = "#0000AA";
nElement.style.color = "#0000AA";
this.activeRow = rowIndex;
17 years, 7 months
JBoss Rich Faces SVN: r1053 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-06 11:03:07 -0400 (Wed, 06 Jun 2007)
New Revision: 1053
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
add id to frozen normal tables, remove GridContainer from general id
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-06-06 15:02:29 UTC (rev 1052)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-06-06 15:03:07 UTC (rev 1053)
@@ -27,12 +27,12 @@
<f:call name="setUpColumnsWidth"/>
- <div id="#{clientId}_GridContainer" style="width: #{component.attributes['width']};height: #{component.attributes['height']};" class="ClientUI_Grid" >
+ <div id="#{clientId}" style="width: #{component.attributes['width']};height: #{component.attributes['height']};" class="ClientUI_Grid" >
<div id="#{clientId}_GridHeaderTemplate" class="ClientUI_InlineBox" style="width: #{component.attributes['width']};">
<div style="display: block; left: 0px; top: 0px; width: #{sumWidth}px;">
<span class="ClientUI_TmplBox ClientUI_FrozenBox" id="#{clientId}:header:FrozenBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:f" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -53,7 +53,7 @@
</span>
<span class="ClientUI_TmplBox ClientUI_NormalBox" id="#{clientId}:header:NormalBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:n" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -79,7 +79,7 @@
<div id="#{clientId}_GridBodyTemplate" class="ClientUI_InlineBox" style="overflow: auto; width: #{component.attributes['width']}; height: #{component.attributes['height']};">
<div style="display: block; width: #{sumWidth}px;">
<span class="ClientUI_TmplBox ClientUI_FrozenBox" id="#{clientId}:body:FrozenBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:f" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -97,7 +97,7 @@
</table>
</span>
<span class="ClientUI_TmplBox ClientUI_NormalBox" id="#{clientId}:body:NormalBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:n" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -120,7 +120,7 @@
<div id="#{clientId}_GridFooterTemplate" class="ClientUI_InlineBox" style="width: #{component.attributes['width']};">
<div style="display: block; width: width: #{sumWidth}px;">
<span class="ClientUI_TmplBox ClientUI_FrozenBox" id="#{clientId}:footer:FrozenBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:f" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -141,7 +141,7 @@
</span>
<span class="ClientUI_TmplBox ClientUI_NormalBox" id="#{clientId}:footer:NormalBox">
- <table cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
+ <table id="#{clientId}:n" cellpadding="0" cellspacing="0" style="border-collapse:collapse; table-layout:fixed">
<jsp:scriptlet>
<![CDATA[
@@ -213,7 +213,7 @@
// currTime = (new Date()).getTime();
// create the Grid
- grid = new ClientUI.controls.grid.Grid(clientId +"_" + 'GridContainer', dataModel, templates,
+ grid = new ClientUI.controls.grid.Grid(clientId, dataModel, templates,
{
showIndexColumn: false,
indexColumnWidth: 40
17 years, 7 months
JBoss Rich Faces SVN: r1052 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-06 11:02:29 -0400 (Wed, 06 Jun 2007)
New Revision: 1052
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
Log:
rename id
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-06 15:01:59 UTC (rev 1051)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-06 15:02:29 UTC (rev 1052)
@@ -44,7 +44,7 @@
rowindex -= rowCount;
}
- id = baseid + ":f:row_" + rowindex;
+ id = baseid + ":f:" + rowindex;
row = request.getElementById(id);
if(ClientUILib.isIE) {
@@ -55,7 +55,7 @@
this.updateTr(el,row.innerHTML);
}
- id = baseid + ":n:row_" + rowindex;
+ id = baseid + ":n:" + rowindex;
row = request.getElementById(id);
if(ClientUILib.isIE) {
el = getEl(id);
17 years, 7 months
JBoss Rich Faces SVN: r1051 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-06 11:01:59 -0400 (Wed, 06 Jun 2007)
New Revision: 1051
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/GridScrollSettings.java
Removed:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/Options.java
Log:
rename to GridScrollSettings
Copied: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/GridScrollSettings.java (from rev 1039, trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/Options.java)
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/GridScrollSettings.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/GridScrollSettings.java 2007-06-06 15:01:59 UTC (rev 1051)
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html.response;
+
+/**
+ * @author Anton Belevich
+ * Class for storing response options
+ */
+public class GridScrollSettings {
+
+ private int index;
+
+ private int startRow;
+
+ private int count;
+
+
+
+ public GridScrollSettings(int index, int startRow, int count) {
+
+ this.index = index;
+
+ this.startRow = startRow;
+
+ this.count = count;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getStartRow() {
+ return startRow;
+ }
+
+ public void setStartRow(int startRow) {
+ this.startRow = startRow;
+ }
+}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/Options.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/Options.java 2007-06-06 15:01:23 UTC (rev 1050)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/response/Options.java 2007-06-06 15:01:59 UTC (rev 1051)
@@ -1,52 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html.response;
-
-/**
- * @author Anton Belevich
- * Class for storing response options
- */
-public class Options {
-
- private int index;
-
- private int startRow;
-
- private int count;
-
-
-
- public Options(int index, int startRow, int count) {
-
- this.index = index;
-
- this.startRow = startRow;
-
- this.count = count;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- public int getStartRow() {
- return startRow;
- }
-
- public void setStartRow(int startRow) {
- this.startRow = startRow;
- }
-}
17 years, 7 months
JBoss Rich Faces SVN: r1050 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-06 11:01:23 -0400 (Wed, 06 Jun 2007)
New Revision: 1050
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-06 14:46:49 UTC (rev 1049)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-06 15:01:23 UTC (rev 1050)
@@ -32,7 +32,7 @@
import org.richfaces.model.selection.Selection;
import org.richfaces.model.selection.SimpleSelection;
import org.richfaces.renderkit.CompositeRenderer;
-import org.richfaces.renderkit.html.response.Options;
+import org.richfaces.renderkit.html.response.GridScrollSettings;
import org.richfaces.utils.TemplateLoader;
@@ -199,9 +199,9 @@
String baseClientId = grid.getBaseClientId(context);
if(state.isFrozenPart()){
- row_id = baseClientId + ":f:row_" + index;
+ row_id = baseClientId + ":f:" + index;
}else{
- row_id = baseClientId + ":n:row_" + index;
+ row_id = baseClientId + ":n:" + index;
}
ResponseWriter writer = context.getResponseWriter();
@@ -262,7 +262,7 @@
state.setFrozenPart(true);
frozenTRRendered = true;
- row_id = baseClientId + ":f:row_" + state.getRowIndex();
+ row_id = baseClientId + ":f:" + state.getRowIndex();
writer.startElement("tr", grid);
getUtils().writeAttribute(writer,"id",row_id);
getUtils().writeAttribute(writer,"class", "ClientUI_Grid_BR");
@@ -275,7 +275,7 @@
}
state.setFrozenPart(false);
- row_id = baseClientId + ":n:row_" + state.getRowIndex();
+ row_id = baseClientId + ":n:" + state.getRowIndex();
writer.startElement("tr", grid);
getUtils().writeAttribute(writer,"id",row_id);
@@ -674,18 +674,18 @@
ajaxContext.setResponseData(grid.getResponseData());
ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
- Options options = createOptions(grid);
+ GridScrollSettings options = createOptions(grid);
ajaxContext.getResponseDataMap().put("options", options);
grid.setRows(grid.getDefaultRows());
}
- private Options createOptions(UIScrollableGrid grid){
+ private GridScrollSettings createOptions(UIScrollableGrid grid){
int index = grid.getRowIndex();
int startRow = ((Integer)grid.getAttributes().get(CLIENT_ROW_KEY)).intValue();
int count = grid.getRows();
- Options options = new Options(index, startRow, count);
+ GridScrollSettings options = new GridScrollSettings(index, startRow, count);
return options;
}
17 years, 7 months
JBoss Rich Faces SVN: r1049 - trunk/docs/userguide/en/included.
by richfaces-svn-commits@lists.jboss.org
Author: vkukharchuk
Date: 2007-06-06 10:46:49 -0400 (Wed, 06 Jun 2007)
New Revision: 1049
Modified:
trunk/docs/userguide/en/included/modalPanel.xml
Log:
Modified: trunk/docs/userguide/en/included/modalPanel.xml
===================================================================
--- trunk/docs/userguide/en/included/modalPanel.xml 2007-06-06 14:40:08 UTC (rev 1048)
+++ trunk/docs/userguide/en/included/modalPanel.xml 2007-06-06 14:46:49 UTC (rev 1049)
@@ -225,7 +225,7 @@
<para>For implementing skinability the components use a <emphasis role="italic">
<property>style class redefinition method</property>
- </emphasis>. Default style classes are mapped on <emphasis role="italic"><property>skin
+</emphasis>. Default style classes are mapped on <emphasis role="italic"><property>skin
parameters</property>.</emphasis></para>
<para>There are two ways to redefine the appearance of all modal panels at once:</para>
17 years, 7 months
JBoss Rich Faces SVN: r1048 - in trunk/sandbox/scrollable-grid: src/main/javascript/ClientUI/controls/grid and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-06-06 10:40:08 -0400 (Wed, 06 Jun 2007)
New Revision: 1048
Added:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
Modified:
trunk/sandbox/scrollable-grid/generatescript.xml
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
Log:
Added a client part of selection.
Modified: trunk/sandbox/scrollable-grid/generatescript.xml
===================================================================
--- trunk/sandbox/scrollable-grid/generatescript.xml 2007-06-06 14:38:21 UTC (rev 1047)
+++ trunk/sandbox/scrollable-grid/generatescript.xml 2007-06-06 14:40:08 UTC (rev 1048)
@@ -43,6 +43,7 @@
<file name="/ClientUI/controls/grid/GridBody.js"/>
<file name="/ClientUI/controls/grid/GridFooter.js"/>
<file name="/ClientUI/controls/grid/Grid.js"/>
+ <file name="/ClientUI/controls/grid/Selection.js"/>
</filelist>
</concat>
</target>
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06 14:38:21 UTC (rev 1047)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06 14:40:08 UTC (rev 1048)
@@ -54,6 +54,7 @@
this.createControl(template);
this.registerEvents();
this.updateLayout();
+ this.selectionManager = new ClientUI.controls.grid.SelectionManager(this.grid.getElement());
},
registerEvents: function() {
Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-06 14:40:08 UTC (rev 1048)
@@ -0,0 +1,428 @@
+ClientUI.controls.grid.Selection = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.Selection'
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.Selection.prototype, {
+ initialize: function() {
+ this.ranges = [];
+ },
+
+ addId: function(id) {
+ id = parseInt(id);
+ if(this.isSelectedId(id))
+ return;
+ var i = 0;
+ while(i < this.ranges.length && id >= this.ranges[i++].indexes[1]);
+ i--;
+ if(this.ranges[i-1] && id==(this.ranges[i-1].indexes[1]+1) ) {
+ if(id==(this.ranges[i].indexes[0]-1)) {
+ this.ranges[i-1].indexes[1] = this.ranges[i].indexes[1];
+ this.removeRange(i);
+ } else {
+ this.ranges[i-1].indexes[1]++;
+ }
+ } else {
+ if(this.ranges[i]){
+ if(this.ranges[i] && id==(this.ranges[i].indexes[0]-1)) {
+ this.ranges[i].indexes[0]--;
+ } else {
+ if(id==(this.ranges[i].indexes[1]+1)){
+ this.ranges[i].indexes[1]++;
+ } else {
+ if(id<this.ranges[i].indexes[1]){
+ this.addRange(i, new ClientUI.controls.grid.Range(id, id));
+ } else {
+ this.addRange(i + 1, new ClientUI.controls.grid.Range(id, id));
+ }
+ }
+ }
+ } else {
+ this.addRange(i, new ClientUI.controls.grid.Range(id, id));
+ }
+ }
+ },
+
+ addRange: function(index, range) {
+ var i = this.ranges.push(range) - 2;
+ if(index >= 0) {
+ while(i>=index)
+ this.ranges[i+1] = this.ranges[i--];
+ this.ranges[i+1] = range;
+ }
+ },
+
+ removeRange: function(index) {
+ var i = index + 1;
+ while(i!=this.ranges.length)
+ this.ranges[i-1] = this.ranges[i++];
+ this.ranges.pop();
+ },
+
+ isSelectedId: function(id) {
+ var i = 0;
+ while(i < this.ranges.length && id >= this.ranges[i].indexes[0]) {
+ if(id >= this.ranges[i].indexes[0] && id <= this.ranges[i].indexes[1]) {
+ return true;
+ } else {
+ i++;
+ }
+ }
+ return false;
+ },
+
+ getSelectedIdsQuantity: function() {
+ var number = 0;
+ for (var i = 0; i < this.ranges.length; i++) {
+ number+= this.ranges[i].size();
+ }
+ return number;
+ },
+
+ size: function () {
+ return this.getSelectedIdsQuantity();
+ },
+
+ removeId: function(id) {
+ id = parseInt(id);
+ if(!this.isSelectedId(id))
+ return;
+ var i = 0;
+ while(i < this.ranges.length && id > this.ranges[i++].indexes[1]);
+ i--;
+ if(this.ranges[i]) {
+ if(id==(this.ranges[i].indexes[1]) ) {
+ if(id==(this.ranges[i].indexes[0])){
+ this.removeRange(i);
+ } else {
+ this.ranges[i].indexes[1]--;
+ }
+ } else {
+ if(id==(this.ranges[i].indexes[0])){
+ this.ranges[i].indexes[0]++;
+ } else {
+ this.addRange(i+1, new ClientUI.controls.grid.Range(id+1, this.ranges[i].indexes[1]));
+ this.ranges[i].indexes[1] = id-1;
+ }
+ }
+ }
+ },
+
+ getRanges: function() {
+ return this.ranges;
+ },
+
+ setRanges: function(ranges) {
+ this.ranges = ranges;
+ },
+
+ initRanges: function(rangesStr) {
+ if(!rangesStr) {
+ this.ranges = [];
+ return;
+ }
+ var rangeStrRArray = rangesStr.split(";");
+ this.ranges = new Array(rangeStrRArray.length -1);
+ var indexStrRArray;
+ for(var i = 0; i < this.ranges.length; i++) {
+ indexStrRArray = rangeStrRArray[i].split(",");
+ this.ranges[i] = new ClientUI.controls.grid.Range(parseInt(indexStrRArray[0]), parseInt(indexStrRArray[1]));
+ }
+
+ },
+
+ inspectRanges: function() {
+ var ranges = this.getRanges();
+ var ret = "";
+ ranges.each( function(r) { ret += r.inspect(); } );
+ return ret;
+ }
+});
+
+ClientUI.controls.grid.Range = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.Range'
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.Range.prototype, {
+ initialize: function(startIndex, endIndex) {
+ this.indexes = [startIndex, endIndex];
+ },
+
+ inspect: function() {
+ return this.indexes[0] + "," + this.indexes[1] + ";";
+ },
+ toString: function() {
+ return this.inspect();
+ },
+
+ size: function() {
+ return this.indexes[1] - this.indexes[0] + 1;;
+ },
+
+ each: function(iterator) {
+ var j = this.indexes[0];
+ while(j <= this.indexes[1]) {
+ iterator(j++);
+ }
+ },
+
+ clone: function() {
+ var ret = Object.extend(new Object(),this);
+ ret.indexes = this.indexes.clone();
+ return ret;
+ }
+});
+
+ClientUI.controls.grid.SelectionManager = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.SelectionManager'
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.SelectionManager.prototype, {
+ initialize: function(gridElement) {
+ this.rowPrefix = $("ClientUI_Box8").parentNode.id.split(":body:FrozenBox")[0];//gridElement.id;
+ this.selection = new ClientUI.controls.grid.Selection();
+// this.restoreState();
+ this.eventKeyPress = this.processKeyDown.bindAsEventListener(this);
+ Event.observe(document, "keypress", this.eventKeyPress);
+ var frows = $("ClientUI_Box8").rows;
+ var nrows = $("ClientUI_Box9").rows;
+ var rowIndex;
+ for(var i = 0; i < frows.length; i++) {
+ rowIndex = Number(frows[i].id.split("_")[2]);
+ this.addListener(frows[i], rowIndex);
+ this.addListener(nrows[i], rowIndex);
+ }
+ if (document.selection) {
+ Event.observe(gridElement, "click", this.resetSelection.bindAsEventListener(this));
+ }
+
+ this.eventLostFocus = this.processLostFocus.bindAsEventListener(this);
+ Event.observe(document, "click", this.eventLostFocus);
+
+ this.eventPreventLostFocus = this.processPreventLostFocus.bindAsEventListener(this);
+ Event.observe(gridElement, "click", this.eventPreventLostFocus);
+
+
+// var selChangeHandler = this.grid.options.onselectionchange;
+// if (selChangeHandler) {
+// IL.Event.observe(this.grid.element, "selectionchange", selChangeHandler);
+// }
+// var deleteHandler = this.grid.options.onDeleted;
+// if (deleteHandler) {
+// IL.Event.observe(this.grid.element, "delete", deleteHandler);
+// }
+
+ },
+
+ addListener: function(element, rowIndex) {
+ Event.observe(element, "click", this.processClick.bindAsEventListener(this, rowIndex));
+ },
+
+
+/* restoreState: function() {
+ this.selection.initRanges(this.grid.options.selectionField.value);
+ this.oldState = this.selection.getState();
+ var i = 0;
+ var j;
+ while(i < this.selection.ranges.length) {
+ j = this.selection.ranges[i].indexes[0];
+ while(j <= this.selection.ranges[i].indexes[1]) {
+ var r = this.grid.getRowFromId(j);
+ if(r) {
+ r.addListener();
+ }
+ j++;
+ }
+ i++;
+ }
+ },
+
+ getGridSelection: function() {
+ return this.selection.getRanges();
+ },*/
+
+ processPreventLostFocus: function() {
+ this.inFocus = true;
+ this.preventLostFocus = true;
+ },
+
+ processLostFocus: function() {
+ if (!this.preventLostFocus) {
+ this.lostFocus();
+ } else {
+ this.preventLostFocus = false;
+ }
+ },
+
+ lostFocus: function() {
+ this.inFocus = false;
+ },
+
+ processKeyDown: function(event) {
+ if(!event.shiftKey) {
+ this.shiftRow = null;
+ }
+ var range, rowIndex;
+ var activeRow = this.activeRow;
+ var noDefault = false;
+ switch (event.keyCode || event.charCode) {
+ case Event.KEY_UP:
+ if (this.inFocus && activeRow && activeRow > 0) {
+ rowIndex = activeRow - 1;
+ if (!event.ctrlKey && !event.shiftKey) {
+ range = [rowIndex, rowIndex];
+ this.setSelection(range);
+ } else if (!event.ctrlKey && event.shiftKey) {
+ if(!this.shiftRow) {
+ this.shiftRow = this.activeRow;
+ }
+ if(this.shiftRow >= this.activeRow) {
+ this.addRowToSelection(rowIndex);
+ } else {
+ this.removeRowFromSelection(activeRow);
+ }
+ }
+ noDefault = true;
+ this.setActiveRow(rowIndex);
+ }
+ break;
+ case Event.KEY_DOWN:
+ if (this.inFocus && activeRow) {
+ rowIndex = activeRow + 1;
+ if (!event.ctrlKey && !event.shiftKey) {
+ range = [rowIndex, rowIndex];
+ this.setSelection(range);
+ } else if (!event.ctrlKey && event.shiftKey) {
+ if(!this.shiftRow) {
+ this.shiftRow = this.activeRow;
+ }
+ if(this.shiftRow <= this.activeRow) {
+ this.addRowToSelection(rowIndex);
+ } else {
+ this.removeRowFromSelection(activeRow);
+ }
+ }
+ noDefault = true;
+ this.setActiveRow(rowIndex);
+ }
+ break;
+ case 65: case 97: // Ctrl-A
+ if (this.inFocus && event.ctrlKey) {
+ range = [0, $("ClientUI_Box8").rows.length];
+ this.setSelection(range);
+ noDefault = true;
+ }
+ break;
+ case Event.KEY_TAB:
+ this.lostFocus();
+ }
+ if (noDefault) {
+ if (event.preventBubble) event.preventBubble();
+ Event.stop(event);
+ }
+ },
+
+ processClick: function(event, rowIndex) {
+ if(!event.shiftKey) {
+ this.shiftRow = null;
+ }
+ var range;
+ if ( event.shiftKey && !event.ctrlKey && !event.altKey) {
+ if(!this.shiftRow) {
+ this.shiftRow = this.activeRow;
+ }
+ this.startRow = this.shiftRow;
+ if (this.startRow <= rowIndex) {
+ this.endRow = rowIndex;
+ } else {
+ this.endRow = this.startRow;
+ this.startRow = rowIndex;
+ }
+ range = [this.startRow, this.endRow];
+ this.setSelection(range);
+ } else if (!event.shiftKey && event.ctrlKey && !event.altKey) {
+ if (this.selection.isSelectedId(rowIndex)) {
+ this.removeRowFromSelection(rowIndex);
+ } else {
+ this.addRowToSelection(rowIndex);
+ }
+ } else if (!event.shiftKey && !event.ctrlKey && !event.altKey) {
+ range = [rowIndex, rowIndex];
+ this.setSelection(range);
+ }
+ this.setActiveRow(rowIndex);
+ if (window.getSelection) {
+ window.getSelection().removeAllRanges();
+ } else if (document.selection) {
+ document.selection.empty();
+ }
+ },
+
+ setShiftRow: function(event) {
+ if(event.shiftKey) {
+ if(!this.shiftRow) {
+ this.shiftRow = this.activeRow;
+ }
+ } else {
+ this.shiftRow = null;
+ }
+ },
+
+ setSelection: function(range) {
+ var i = 0;
+ for (; i < range[0]; i++) {
+ this.removeRowFromSelection(i);
+ }
+ for (; i <= range[1]; i++) {
+ this.addRowToSelection(i);
+ }
+ for (; i < $("ClientUI_Box8").rows.length; i++) {
+ this.removeRowFromSelection(i);
+ }
+ },
+
+ resetSelection: function(e) {
+ if(e.shiftKey) {
+ document.selection.empty();
+ }
+ },
+
+ addRowToSelection: function(rowIndex) {
+ this.selection.addId(rowIndex);
+ var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ fElement.style.backgroundColor = "#DDDDFF";
+ nElement.style.backgroundColor = "#DDDDFF";
+ },
+
+ removeRowFromSelection: function(rowIndex) {
+ this.selection.removeId(rowIndex);
+ var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ fElement.style.backgroundColor = "#FFFFFF";
+ nElement.style.backgroundColor = "#FFFFFF";
+ },
+
+ setActiveRow: function(rowIndex) {
+ var fElement, nElement;
+ if(this.activeRow) {
+ fElement = $(this.rowPrefix + ":f:row_" + this.activeRow);
+ nElement = $(this.rowPrefix + ":n:row_" + this.activeRow);
+ fElement.style.color = "#000000";
+ nElement.style.color = "#000000";
+ }
+ fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
+ nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ fElement.style.color = "#0000AA";
+ nElement.style.color = "#0000AA";
+ this.activeRow = rowIndex;
+ }
+});
\ No newline at end of file
17 years, 7 months