JBoss Rich Faces SVN: r20859 - in trunk/ui/input/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-31 10:41:35 -0500 (Fri, 31 Dec 2010)
New Revision: 20859
Added:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/jquery.mousewheel.js
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
trunk/ui/input/ui/src/main/templates/inputnumberspinner.template.xml
Log:
RF-9638
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2010-12-31 15:17:08 UTC (rev 20858)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2010-12-31 15:41:35 UTC (rev 20859)
@@ -68,6 +68,7 @@
var proxy = jQuery.proxy(this.__inputHandler, this);
this.input.change(proxy);
this.input.submit(proxy);
+ this.element.mousewheel(jQuery.proxy(this.__mousewheelHandler, this));
this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
this.decreaseButton.mousedown(jQuery.proxy(this.__decreaseHandler, this));
this.increaseButton.mousedown(jQuery.proxy(this.__increaseHandler, this));
@@ -119,6 +120,16 @@
}
},
+ __mousewheelHandler: function (event, delta, deltaX, deltaY) {
+ delta = deltaX || deltaY;
+ if (delta > 0) {
+ this.increase(event);
+ } else if (delta < 0) {
+ this.decrease(event);
+ }
+ return false;
+ },
+
__keydownHandler: function (event) {
if (event.keyCode == 37) { //LEFT
this.__setValue(Number(this.input.val()) - this.step, event);
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-31 15:17:08 UTC (rev 20858)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSpinner.js 2010-12-31 15:41:35 UTC (rev 20859)
@@ -53,6 +53,7 @@
this.input.change(proxy);
this.input.submit(proxy);
this.input.submit(proxy);
+ this.input.mousewheel(jQuery.proxy(this.__mousewheelHandler, this));
this.input.keydown(jQuery.proxy(this.__keydownHandler, this));
this.decreaseButton.mousedown(jQuery.proxy(this.__decreaseHandler, this));
this.increaseButton.mousedown(jQuery.proxy(this.__increaseHandler, this));
@@ -123,6 +124,16 @@
}
},
+ __mousewheelHandler: function (event, delta, deltaX, deltaY) {
+ delta = deltaX || deltaY;
+ if (delta > 0) {
+ this.increase(event);
+ } else if (delta < 0) {
+ this.decrease(event);
+ }
+ return false;
+ },
+
__keydownHandler: function (event) {
if (event.keyCode == 40) { //DOWN
this.decrease(event);
Added: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/jquery.mousewheel.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/jquery.mousewheel.js (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/jquery.mousewheel.js 2010-12-31 15:41:35 UTC (rev 20859)
@@ -0,0 +1,78 @@
+/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
+ * Licensed under the MIT License (LICENSE.txt).
+ *
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
+ *
+ * Version: 3.0.4
+ *
+ * Requires: 1.2.2+
+ */
+
+(function($) {
+
+var types = ['DOMMouseScroll', 'mousewheel'];
+
+$.event.special.mousewheel = {
+ setup: function() {
+ if ( this.addEventListener ) {
+ for ( var i=types.length; i; ) {
+ this.addEventListener( types[--i], handler, false );
+ }
+ } else {
+ this.onmousewheel = handler;
+ }
+ },
+
+ teardown: function() {
+ if ( this.removeEventListener ) {
+ for ( var i=types.length; i; ) {
+ this.removeEventListener( types[--i], handler, false );
+ }
+ } else {
+ this.onmousewheel = null;
+ }
+ }
+};
+
+$.fn.extend({
+ mousewheel: function(fn) {
+ return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
+ },
+
+ unmousewheel: function(fn) {
+ return this.unbind("mousewheel", fn);
+ }
+});
+
+
+function handler(event) {
+ var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
+ event = $.event.fix(orgEvent);
+ event.type = "mousewheel";
+
+ // Old school scrollwheel delta
+ if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
+ if ( event.detail ) { delta = -event.detail/3; }
+
+ // New school multidimensional scroll (touchpads) deltas
+ deltaY = delta;
+
+ // Gecko
+ if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
+ deltaY = 0;
+ deltaX = -1*delta;
+ }
+
+ // Webkit
+ if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
+ if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
+
+ // Add event and delta to the front of the arguments
+ args.unshift(event, delta, deltaX, deltaY);
+
+ return $.event.handle.apply(this, args);
+}
+
+})(jQuery);
\ No newline at end of file
Modified: trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2010-12-31 15:17:08 UTC (rev 20858)
+++ trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2010-12-31 15:41:35 UTC (rev 20859)
@@ -34,6 +34,7 @@
<cdk:resource-dependency library="org.richfaces" name="inputNumberSlider.ecss" />
<cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
<cdk:resource-dependency name="jquery.position.js" />
+ <cdk:resource-dependency library="org.richfaces" name="jquery.mousewheel.js" />
<cdk:resource-dependency library="org.richfaces" name="inputNumberSlider.js" />
</cc:interface>
<cc:implementation>
Modified: trunk/ui/input/ui/src/main/templates/inputnumberspinner.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inputnumberspinner.template.xml 2010-12-31 15:17:08 UTC (rev 20858)
+++ trunk/ui/input/ui/src/main/templates/inputnumberspinner.template.xml 2010-12-31 15:41:35 UTC (rev 20859)
@@ -34,6 +34,7 @@
<cdk:resource-dependency library="org.richfaces" name="inputNumberSpinner.ecss" />
<cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
<cdk:resource-dependency name="jquery.position.js" />
+ <cdk:resource-dependency library="org.richfaces" name="jquery.mousewheel.js" />
<cdk:resource-dependency library="org.richfaces" name="inputNumberSpinner.js" />
</cc:interface>
<cc:implementation>
14 years
JBoss Rich Faces SVN: r20858 - trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-31 10:17:08 -0500 (Fri, 31 Dec 2010)
New Revision: 20858
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.ecss
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
Log:
RF-8912
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.ecss
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.ecss 2010-12-31 12:04:09 UTC (rev 20857)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.ecss 2010-12-31 15:17:08 UTC (rev 20858)
@@ -110,20 +110,27 @@
}
.rf-edt-c, .rf-edt-hdr-c, .rf-edt-ftr-c {
- height: 20px;
- overflow: hidden;
+ overflow-x: hidden;
border-bottom: '#{richSkin.tableBorderWidth} solid #{richSkin.tableBorderColor}';
border-right: '#{richSkin.tableBorderWidth} solid #{richSkin.tableBorderColor}';
}
+.rf-edt-c {
+ height: 20px;
+ overflow: hidden;
+}
+
.rf-edt-ftr-c-emp {
border-right: '#{richSkin.tableBorderWidth} solid #{richSkin.tableBorderColor}';
height: 1px;
}
+.rf-edt-c-cnt {
+ white-space: nowrap;
+}
+
.rf-edt-c-cnt, .rf-edt-hdr-c-cnt, .rf-edt-ftr-c-cnt, .rf-edt-tbl-hdr, .rf-edt-tbl-ftr {
padding: 3px 7px;
- white-space: nowrap;
font-family: '#{richSkin.generalFamilyFont}';
font-size: '#{richSkin.generalSizeFont}';
}
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-31 12:04:09 UTC (rev 20857)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-31 15:17:08 UTC (rev 20858)
@@ -160,6 +160,8 @@
this.widthInput = document.getElementById(id + ":wi");
this.selectionInput = document.getElementById(id + ":si");
this.header = jQuery(this.element).children(".rf-edt-hdr");
+ this.headerCells = this.header.find(".rf-edt-hdr-c");
+ this.footerCells = jQuery(this.element).children(".rf-edt-ftr").find(".rf-edt-ftr-c");
this.resizerHolders = this.header.find(".rf-edt-rsz-cntr");
this.frozenHeaderPartElement = document.getElementById(id + ":frozenHeader");
@@ -176,9 +178,8 @@
getColumnPosition: function(id) {
var position;
- var headers = this.header.find(".rf-edt-hdr-c");
- for (var i = 0; i < headers.length; i++) {
- if (id == headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
+ for (var i = 0; i < this.headerCells.length; i++) {
+ if (id == this.headerCells[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
position = i;
}
}
@@ -188,9 +189,8 @@
setColumnPosition: function(id, position) {
var colunmsOrder = "";
var before;
- var headers = this.header.find(".rf-edt-hdr-c");
- for (var i = 0; i < headers.length; i++) {
- var current = headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ for (var i = 0; i < this.headerCells.length; i++) {
+ var current = this.headerCells[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
if (i == position) {
if (before) {
colunmsOrder += current + "," + id + ",";
@@ -256,10 +256,26 @@
bindHeaderHandlers: function() {
this.header.find(".rf-edt-rsz").bind("mousedown", jQuery.proxy(this.beginResize, this));
- this.header.find(".rf-edt-hdr-c").bind("mousedown", jQuery.proxy(this.beginReorder, this));
+ this.headerCells.bind("mousedown", jQuery.proxy(this.beginReorder, this));
},
updateLayout: function() {
+ this.headerCells.height("auto");
+ var headerCellHeight = 0;
+ this.headerCells.each(function() {
+ if (this.clientHeight > headerCellHeight) {
+ headerCellHeight = this.clientHeight;
+ }
+ });
+ this.headerCells.height(headerCellHeight + "px");
+ this.footerCells.height("auto");
+ var footerCellHeight = 0;
+ this.footerCells.each(function() {
+ if (this.clientHeight > footerCellHeight) {
+ footerCellHeight = this.clientHeight;
+ }
+ });
+ this.footerCells.height(footerCellHeight + "px");
this.normalPartStyle.width = "auto";
var offsetWidth = this.frozenHeaderPartElement ? this.frozenHeaderPartElement.offsetWidth : 0;
var width = Math.max(0, this.element.clientWidth - offsetWidth);
@@ -406,7 +422,7 @@
if (!jQuery(event.currentTarget).is("a, img, :input")) {
this.idOfReorderingColumn = event.currentTarget.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
jQuery(document).bind("mousemove", jQuery.proxy(this.reorder, this));
- this.header.find(".rf-edt-hdr-c").bind("mouseover", jQuery.proxy(this.overReorder, this));
+ this.headerCells.bind("mouseover", jQuery.proxy(this.overReorder, this));
jQuery(document).one("mouseup", jQuery.proxy(this.cancelReorder, this));
return false;
}
@@ -434,7 +450,7 @@
var id = event.currentTarget.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
var colunmsOrder = "";
var _this = this;
- this.header.find(".rf-edt-hdr-c").each(function() {
+ this.headerCells.each(function() {
var i = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
if (i == id) {
colunmsOrder += _this.idOfReorderingColumn + "," + id + ",";
@@ -447,7 +463,7 @@
cancelReorder: function(event) {
jQuery(document).unbind("mousemove", this.reorder);
- this.header.find(".rf-edt-hdr-c").unbind("mouseover", this.overReorder);
+ this.headerCells.unbind("mouseover", this.overReorder);
this.reorderElement.style.display = "none";
},
14 years
JBoss Rich Faces SVN: r20857 - in trunk/ui/output/ui/src: test/java/org/richfaces/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-31 07:04:09 -0500 (Fri, 31 Dec 2010)
New Revision: 20857
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/CollapsiblePanelRendererTest.java
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
Log:
RF-9435
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-12-31 10:16:36 UTC (rev 20856)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-12-31 12:04:09 UTC (rev 20857)
@@ -59,16 +59,16 @@
public static final String SWITCH = "switch";
public static final String BEFORE_SWITCH = "beforeswitch";
- private final TableIconsRendererHelper headerRenderer = new TableIconsRendererHelper("header", "rf-cp-") {
+ private final TableIconsRendererHelper headerRenderer = new TableIconsRendererHelper("header", "rf-cp", "rf-cp-ico-") {
- protected void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ protected void encodeHeaderIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
HtmlCollapsiblePanel panel = (HtmlCollapsiblePanel) component;
encodeTdIcon(writer, context, cssClassPrefix + "-ico", panel.isExpanded(),
panel.getLeftCollapsedIcon(), panel.getLeftExpandedIcon());
}
- protected void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ protected void encodeHeaderIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
HtmlCollapsiblePanel panel = (HtmlCollapsiblePanel) component;
//TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-31 10:16:36 UTC (rev 20856)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-31 12:04:09 UTC (rev 20857)
@@ -59,10 +59,10 @@
private static class HeaderRenderer extends TableIconsRendererHelper {
public HeaderRenderer(String cssClassPrefix) {
- super("label", cssClassPrefix);
+ super("label", cssClassPrefix, "rf-pm-ico-");
}
- protected void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ protected void encodeHeaderIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
HtmlPanelMenuGroup group = (HtmlPanelMenuGroup) component;
String iconCollapsed = group.isDisabled() ? group.getIconLeftDisabled() : group.getIconLeftCollapsed();
@@ -71,7 +71,7 @@
encodeTdIcon(writer, context, cssClassPrefix + "-ico", group.isExpanded(), iconCollapsed, iconExpanded);
}
- protected void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ protected void encodeHeaderIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
HtmlPanelMenuGroup group = (HtmlPanelMenuGroup) component;
String iconCollapsed = group.isDisabled() ? group.getIconRightDisabled() : group.getIconRightCollapsed();
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-31 10:16:36 UTC (rev 20856)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-31 12:04:09 UTC (rev 20857)
@@ -15,10 +15,12 @@
protected final String text;
protected final String cssClassPrefix;
+ protected final String cssIconsClassPrefix;
- public TableIconsRendererHelper(String text, String cssClassPrefix) {
+ public TableIconsRendererHelper(String text, String cssClassPrefix, String cssIconsClassPrefix) {
this.text = text;
this.cssClassPrefix = cssClassPrefix;
+ this.cssIconsClassPrefix = cssIconsClassPrefix;
}
public void encodeHeader(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
@@ -27,11 +29,23 @@
writer.startElement(TBODY_ELEMENT, null);
writer.startElement(TR_ELEMENT, null);
- encodeHeaderGroupIconLeft(writer, context, component);
+ encodeHeaderIconLeft(writer, context, component);
+ encodeHeaderText(writer, context, component);
+ encodeHeaderIconRight(writer, context, component);
+ writer.endElement(TR_ELEMENT);
+ writer.endElement(TBODY_ELEMENT);
+ writer.endElement(TABLE_ELEMENT);
+ }
+
+ private void encodeHeaderText(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
writer.startElement(TD_ELEM, null);
writer.writeAttribute(CLASS_ATTRIBUTE, cssClassPrefix + "-lbl", null);
+ encodeHeaderTextValue(writer, context, component);
+ writer.endElement(TD_ELEM);
+ }
+ protected void encodeHeaderTextValue(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
UIComponent headerFacet = component.getFacet(text);
if (headerFacet != null && headerFacet.isRendered()) {
headerFacet.encodeAll(context);
@@ -41,26 +55,18 @@
writer.writeText(label, null);
}
}
-
- writer.endElement(TD_ELEM);
-
- encodeHeaderGroupIconRight(writer, context, component);
-
- writer.endElement(TR_ELEMENT);
- writer.endElement(TBODY_ELEMENT);
- writer.endElement(TABLE_ELEMENT);
}
- protected abstract void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
+ protected abstract void encodeHeaderIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
- protected abstract void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent menuItem) throws IOException;
+ protected abstract void encodeHeaderIconRight(ResponseWriter writer, FacesContext context, UIComponent menuItem) throws IOException;
protected void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
writer.startElement(TD_ELEM, null);
writer.writeAttribute(CLASS_ATTRIBUTE, cssClass, null);
- encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, cssClassPrefix + "-colps");
- encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, cssClassPrefix + "-exp");
+ encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, cssIconsClassPrefix + "colps");
+ encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, cssIconsClassPrefix + "exp");
writer.endElement(TD_ELEM);
}
Added: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/CollapsiblePanelRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/CollapsiblePanelRendererTest.java (rev 0)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/CollapsiblePanelRendererTest.java 2010-12-31 12:04:09 UTC (rev 20857)
@@ -0,0 +1,14 @@
+package org.richfaces.renderkit.html;
+
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+public class CollapsiblePanelRendererTest extends RendererTestBase {
+
+ @Test
+ public void testEmpty() throws IOException, SAXException {
+// doTest("panelMenuGroup", "f:panelMenuGroup");
+ }
+}
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-31 10:16:36 UTC (rev 20856)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-31 12:04:09 UTC (rev 20857)
@@ -37,7 +37,6 @@
* @author akolonitsky
* @since 2010-10-25
*/
-@Ignore
public class PanelMenuGroupRendererTest extends RendererTestBase {
@Test
14 years
JBoss Rich Faces SVN: r20856 - in trunk/examples/richfaces-showcase/src/main: java/org/richfaces/demo/tree/model and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-12-31 05:16:36 -0500 (Fri, 31 Dec 2010)
New Revision: 20856
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
Log:
https://issues.jboss.org/browse/RF-9833
+ fileUpload sources added
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-31 10:16:36 UTC (rev 20856)
@@ -33,6 +33,7 @@
import javax.faces.bean.ManagedProperty;
import javax.swing.tree.TreeNode;
+import org.richfaces.component.UITree;
import org.richfaces.demo.tree.model.CD;
import org.richfaces.demo.tree.model.Company;
import org.richfaces.demo.tree.model.Country;
@@ -50,7 +51,8 @@
private List<TreeNode> rootNodes = new ArrayList<TreeNode>();
private Map<String, Country> countriesCache = new HashMap<String, Country>();
private Map<String, Company> companiesCache = new HashMap<String, Company>();
- private Object currentSelection;
+ private TreeNode currentSelection = null;
+
@PostConstruct
public void init() {
for (CDXmlDescriptor current : cdXmlDescriptors) {
@@ -62,12 +64,17 @@
company.getCds().add(cd);
}
}
-
- public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent){
- //considering only single selection
+
+ public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent) {
+ // considering only single selection
List<Object> selection = new ArrayList<Object>(selectionChangeEvent.getNewSelection());
- currentSelection = selection.get(0);
-
+ Object currentSelectionKey = selection.get(0);
+ UITree tree = (UITree) selectionChangeEvent.getSource();
+
+ Object storedKey = tree.getRowKey();
+ tree.setRowKey(currentSelectionKey);
+ currentSelection = (TreeNode) tree.getRowData();
+ tree.setRowKey(storedKey);
}
private Country getCountryByName(CDXmlDescriptor descriptor) {
@@ -111,4 +118,12 @@
this.rootNodes = rootNodes;
}
+ public TreeNode getCurrentSelection() {
+ return currentSelection;
+ }
+
+ public void setCurrentSelection(TreeNode currentSelection) {
+ this.currentSelection = currentSelection;
+ }
+
}
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java 2010-12-31 10:16:36 UTC (rev 20856)
@@ -7,24 +7,31 @@
public class CD extends NamedNode implements TreeNode {
private Company company;
private String artist;
- private String title;
private float price;
private int year;
public CD() {
this.setType("cd");
}
-
- public CD(String title, String artist, Company company, float price, int year) {
+
+ public CD(String name, String artist, Company company, float price, int year) {
super();
this.setType("cd");
this.company = company;
this.artist = artist;
- this.title = title;
+ this.name = name;
this.price = price;
this.year = year;
}
+ public Company getCompany() {
+ return company;
+ }
+
+ public void setCompany(Company company) {
+ this.company = company;
+ }
+
public TreeNode getChildAt(int childIndex) {
return null;
}
@@ -70,14 +77,6 @@
this.artist = artist;
}
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
public float getPrice() {
return price;
}
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java 2010-12-31 10:16:36 UTC (rev 20856)
@@ -9,10 +9,9 @@
import com.google.common.collect.Iterators;
public class Company extends NamedNode implements TreeNode {
- private String name;
private List<CD> cds = new ArrayList<CD>();
private Country country;
-
+
public Company() {
this.setType("company");
}
@@ -49,14 +48,6 @@
return Iterators.asEnumeration(cds.iterator());
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public Country getCountry() {
return country;
}
@@ -68,5 +59,5 @@
public List<CD> getCds() {
return cds;
}
-
+
}
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java 2010-12-31 10:16:36 UTC (rev 20856)
@@ -10,7 +10,6 @@
public class Country extends NamedNode implements TreeNode {
- private String name;
private List<Company> companies = new ArrayList<Company>();
public Country() {
@@ -45,14 +44,6 @@
return Iterators.asEnumeration(companies.iterator());
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
public List<Company> getCompanies() {
return companies;
}
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/NamedNode.java 2010-12-31 10:16:36 UTC (rev 20856)
@@ -2,9 +2,18 @@
import java.io.Serializable;
-public class NamedNode implements Serializable{
- private String type;
+public class NamedNode implements Serializable {
+ protected String type;
+ protected String name;
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
public String getType() {
return type;
}
@@ -12,4 +21,9 @@
public void setType(String type) {
this.type = type;
}
+
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
Modified: trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-31 10:16:36 UTC (rev 20856)
@@ -172,10 +172,21 @@
</demo>
</demos>
</group>
- <!-- group> <name>Validation</name> <demos> <demo> <id>clientValidation</id>
- <name>Ajax/Client Validation</name> <samples> <sample> <id>ajaxValidation</id>
- <name>Simple Ajax Validation</name> </sample> </samples> </demo> </demos>
- </group -->
+ <!-- group>
+ <name>Validation</name>
+ <demos>
+ <demo new="true">
+ <id>clientValidation</id>
+ <name>Ajax/Client Validation</name>
+ <samples>
+ <sample>
+ <id>simple</id>
+ <name>Simple Ajax Validation</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group-->
<group>
<name>Data Iteration</name>
<demos>
@@ -281,11 +292,11 @@
<group>
<name>Trees</name>
<demos>
- <demo>
+ <demo new="true">
<id>tree</id>
<name>rich:tree</name>
<samples>
- <sample>
+ <sample new="true">
<id>tree</id>
<name>Simple tree from XML</name>
</sample>
@@ -300,7 +311,7 @@
<name>Simple treeModelRecursiveAdaptor usage</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
<group>
@@ -545,25 +556,25 @@
<name>Upload images</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
- <group>
- <name>Drag and Drop</name>
- <demos>
- <demo new="true">
- <id>dragDrop</id>
- <name>Drag and Drop</name>
- <samples>
- <sample>
- <id>dragDrop</id>
- <name>Drag and Drop usage example</name>
- </sample>
- </samples>
- </demo>
- </demos>
- </group>
<group>
+ <name>Drag and Drop</name>
+ <demos>
+ <demo new="true">
+ <id>dragDrop</id>
+ <name>Drag and Drop</name>
+ <samples>
+ <sample>
+ <id>dragDrop</id>
+ <name>Drag and Drop usage example</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
<name>Misc Components/Features</name>
<demos>
<demo>
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/imgUpload.xhtml 2010-12-31 10:16:36 UTC (rev 20856)
@@ -24,6 +24,12 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/fileupload/FileUploadBean.java"/>
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View FileUploadBean.java" />
+ <ui:param name="hideLabel" value="Hide FileUploadBean.java" />
+ </ui:include>
<p><b>FileUpload requires two context-parameter's to be set in
web.xml:</b></p>
<ul>
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-31 10:16:36 UTC (rev 20856)
@@ -5,18 +5,55 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
-
- <rich:tree id="tree" nodeType="#{node.type}" var="node"
- value="#{treeBean.rootNodes}" toggleType="client"
- >
- <rich:treeNode type="country">
+ <style>
+ .top{
+ vertical-align: top;
+ width: 50%;
+ }
+ .bold{
+ font-weight: bold;
+ }
+ </style>
+ <h:panelGrid columns="2" columnClasses="top,top" width="60%">
+ <h:form>
+ <rich:tree id="tree" nodeType="#{node.type}" var="node"
+ value="#{treeBean.rootNodes}" toggleType="client"
+ selectionType="ajax"
+ selectionChangeListener="#{treeBean.selectionChanged}">
+ <rich:treeNode type="country">
#{node.name}
</rich:treeNode>
- <rich:treeNode type="company" icon="/images/tree/disc.gif">
+ <rich:treeNode type="company" icon="/images/tree/disc.gif">
#{node.name}
</rich:treeNode>
- <rich:treeNode type="cd" icon="/images/tree/song.gif">
- #{node.artist} - #{node.title} - #{node.year}
+ <rich:treeNode type="cd" icon="/images/tree/song.gif">
+ #{node.artist} - #{node.name} - #{node.year}
</rich:treeNode>
- </rich:tree>
+ </rich:tree>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true" layout="block">
+ <rich:panel header="Current Selection"
+ rendered="#{not empty treeBean.currentSelection}">
+ <h:outputText value="Name:" />
+ <h:outputText value="#{treeBean.currentSelection.name}" />
+ <h:panelGroup rendered="#{treeBean.currentSelection.leaf}">
+ <fieldset><legend>Details</legend> <h:panelGrid columnClasses="bold"
+ columns="2">
+ <h:outputText value="Country:" />
+ <h:outputText value="#{treeBean.currentSelection.company.country}" />
+ <h:outputText value="Company:" />
+ <h:outputText value="#{treeBean.currentSelection.company}" />
+ <h:outputText value="Artist:" />
+ <h:outputText value="#{treeBean.currentSelection.artist}" />
+ <h:outputText value="Price:" />
+ <h:outputText value="#{treeBean.currentSelection.price}">
+ <f:convertNumber type="currency" currencyCode="USD"/>
+ </h:outputText>
+ <h:outputText value="Year:" />
+ <h:outputText value="#{treeBean.currentSelection.year}" />
+ </h:panelGrid></fieldset>
+ </h:panelGroup>
+ </rich:panel>
+ </a4j:outputPanel>
+ </h:panelGrid>
</ui:composition>
\ No newline at end of file
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml 2010-12-31 08:29:12 UTC (rev 20855)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml 2010-12-31 10:16:36 UTC (rev 20856)
@@ -5,15 +5,17 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
- <p><b>rich:tree</b> is a component that renders a tree control on the page. The
- most important tree features are:</p>
- <ul>
+ <p><b>rich:tree</b> is a component that renders a tree control on
+ the page. The most important tree features are:</p>
+ <ul>
<li>Native support for Ajax operations</li>
<li>Support for "ajax", "client" and "server" switch types</li>
<li>Selection capabilities</li>
<li>Flexible look</li>
</ul>
-
+ <p>This demo also provides simple selection handling sample. When
+ you will select some node its name will be shown. And when you will
+ select a leaf - full CD details will be populated.</p>
<ui:include src="#{demoNavigator.sampleIncludeURI}" />
<ui:include src="/templates/includes/source-view.xhtml">
<ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
@@ -21,6 +23,37 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/tree/TreeBean.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View TreeBean.java" />
+ <ui:param name="hideLabel" value="Hide TreeBean.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/tree/model/Country.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View Country.java" />
+ <ui:param name="hideLabel" value="Hide Country.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/tree/model/Company.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View Company.java" />
+ <ui:param name="hideLabel" value="Hide Company.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/tree/model/CD.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CD.java" />
+ <ui:param name="hideLabel" value="Hide CD.java" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="/WEB-INF/src/org/richfaces/demo/tree/model/NamedNode.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View NamedNode.java" />
+ <ui:param name="hideLabel" value="Hide NamedNode.java" />
+ </ui:include>
+
</ui:composition>
</html>
\ No newline at end of file
14 years
JBoss Rich Faces SVN: r20855 - in trunk/examples/richfaces-showcase/src/main: webapp/richfaces/fileUpload/samples and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-12-31 03:29:12 -0500 (Fri, 31 Dec 2010)
New Revision: 20855
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml
Log:
https://issues.jboss.org/browse/RF-9974
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java 2010-12-31 07:39:15 UTC (rev 20854)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/fileupload/FileUploadBean.java 2010-12-31 08:29:12 UTC (rev 20855)
@@ -1,15 +1,16 @@
package org.richfaces.demo.fileupload;
-import org.richfaces.event.FileUploadEvent;
-import org.richfaces.model.UploadedFile;
-
-import javax.faces.bean.ManagedBean;
-import javax.faces.bean.SessionScoped;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.ArrayList;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.event.FileUploadEvent;
+import org.richfaces.model.UploadedFile;
+
/**
* @author Ilya Shaikovsky
*
@@ -18,30 +19,16 @@
@SessionScoped
public class FileUploadBean implements Serializable {
- private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();
+ private ArrayList<UploadedFile> files = new ArrayList<UploadedFile>();
private int uploadsAvailable = 5;
- private boolean autoUpload = false;
- private boolean useFlash = false;
- public int getSize() {
- if (getFiles().size() > 0) {
- return getFiles().size();
- } else {
- return 0;
- }
- }
-
public void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer) object).getData());
+ stream.close();
}
public void listener(FileUploadEvent event) throws Exception {
- UploadedFile item = event.getUploadedFile();
- UploadedImage file = new UploadedImage();
- file.setLength(item.getData().length);
- file.setName(item.getName());
- file.setData(item.getData());
- files.add(file);
+ files.add(event.getUploadedFile());
uploadsAvailable--;
}
@@ -51,18 +38,26 @@
return null;
}
- public long getTimeStamp() {
- return System.currentTimeMillis();
+ public int getSize() {
+ if (getFiles().size() > 0) {
+ return getFiles().size();
+ } else {
+ return 0;
+ }
}
- public ArrayList<UploadedImage> getFiles() {
+ public ArrayList<UploadedFile> getFiles() {
return files;
}
- public void setFiles(ArrayList<UploadedImage> files) {
+ public void setFiles(ArrayList<UploadedFile> files) {
this.files = files;
}
+ public long getTimeStamp() {
+ return System.currentTimeMillis();
+ }
+
public int getUploadsAvailable() {
return uploadsAvailable;
}
@@ -71,20 +66,4 @@
this.uploadsAvailable = uploadsAvailable;
}
- public boolean isAutoUpload() {
- return autoUpload;
- }
-
- public void setAutoUpload(boolean autoUpload) {
- this.autoUpload = autoUpload;
- }
-
- public boolean isUseFlash() {
- return useFlash;
- }
-
- public void setUseFlash(boolean useFlash) {
- this.useFlash = useFlash;
- }
-
}
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml 2010-12-31 07:39:15 UTC (rev 20854)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/fileUpload/samples/imgUpload-sample.xhtml 2010-12-31 08:29:12 UTC (rev 20855)
@@ -36,7 +36,7 @@
var="file" rowKeyVar="row">
<rich:panel bodyClass="rich-laguna-panel-no-header">
<h:panelGrid columns="2">
- <a4j:mediaOutput element="img" mimeType="#{file.mime}"
+ <a4j:mediaOutput element="img" mimeType="image/jpeg"
createContent="#{fileUploadBean.paint}" value="#{row}"
style="width:100px; height:100px;" cacheable="false">
<f:param value="#{fileUploadBean.timeStamp}" name="time" />
@@ -45,7 +45,7 @@
<h:outputText value="File Name:" />
<h:outputText value="#{file.name}" />
<h:outputText value="File Length(bytes):" />
- <h:outputText value="#{file.length}" />
+ <h:outputText value="#{file.size}" />
</h:panelGrid>
</h:panelGrid>
</rich:panel>
14 years
JBoss Rich Faces SVN: r20854 - in trunk/ui/output/ui/src: test/java/org/richfaces/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-31 02:39:15 -0500 (Fri, 31 Dec 2010)
New Revision: 20854
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
Log:
RF-9435 collapsible panel implement controls and different collapse modes
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-12-30 23:45:12 UTC (rev 20853)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-12-31 07:39:15 UTC (rev 20854)
@@ -22,28 +22,22 @@
package org.richfaces.renderkit.html;
-import static org.richfaces.component.AbstractCollapsiblePanel.States.collapsed;
-import static org.richfaces.component.AbstractCollapsiblePanel.States.expanded;
-import static org.richfaces.renderkit.HtmlConstants.CLASS_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.DIV_ELEM;
-import static org.richfaces.renderkit.HtmlConstants.ID_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.STYLE_ATTRIBUTE;
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractCollapsiblePanel;
+import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.component.html.HtmlCollapsiblePanel;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-import org.ajax4jsf.javascript.JSObject;
-import org.richfaces.component.AbstractCollapsiblePanel;
-import org.richfaces.component.AbstractTogglePanel;
-import org.richfaces.component.AbstractTogglePanelTitledItem;
+import static org.richfaces.renderkit.HtmlConstants.*;
/**
* @author akolonitsky
@@ -65,6 +59,28 @@
public static final String SWITCH = "switch";
public static final String BEFORE_SWITCH = "beforeswitch";
+ private final TableIconsRendererHelper headerRenderer = new TableIconsRendererHelper("header", "rf-cp-") {
+
+ protected void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ HtmlCollapsiblePanel panel = (HtmlCollapsiblePanel) component;
+
+ encodeTdIcon(writer, context, cssClassPrefix + "-ico", panel.isExpanded(),
+ panel.getLeftCollapsedIcon(), panel.getLeftExpandedIcon());
+ }
+
+ protected void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ HtmlCollapsiblePanel panel = (HtmlCollapsiblePanel) component;
+
+ //TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
+ encodeTdIcon(writer, context, cssClassPrefix + "-exp-ico", panel.isExpanded(),
+ panel.getRightCollapsedIcon(), panel.getRightExpandedIcon());
+ }
+ };
+
+ public TableIconsRendererHelper getHeaderRenderer() {
+ return headerRenderer;
+ }
+
@Override
protected void doDecode(FacesContext context, UIComponent component) {
AbstractTogglePanel panel = (AbstractTogglePanel) component;
@@ -126,31 +142,11 @@
writer.writeAttribute(ID_ATTRIBUTE, component.getClientId(context) + ":header", null);
writer.writeAttribute(CLASS_ATTRIBUTE, concatClasses("rf-cp-hdr", attributeAsString(component, "headerClass")), null);
- AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
- encodeHeader(context, component, writer, expanded, panel.isExpanded());
- encodeHeader(context, component, writer, collapsed, !panel.isExpanded());
+ headerRenderer.encodeHeader(writer, context, component);
writer.endElement(DIV_ELEM);
}
- private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter responseWriter, AbstractCollapsiblePanel.States state, boolean isVisible) throws IOException {
- responseWriter.startElement(DIV_ELEM, component);
- responseWriter.writeAttribute(CLASS_ATTRIBUTE, "rf-cp-hdr-" + state.abbreviation(), null);
- responseWriter.writeAttribute(STYLE_ATTRIBUTE, concatStyles(styleElement("display", isVisible ? "" : "none"), attributeAsString(component, "headerClass")), null);
-
- UIComponent header = AbstractTogglePanelTitledItem.getHeaderFacet(component, state);
- if (header != null && header.isRendered()) {
- header.encodeAll(context);
- } else {
- String headerText = (String) component.getAttributes().get("header");
- if (headerText != null && headerText.length() > 0) {
- responseWriter.writeText(headerText, null);
- }
- }
-
- responseWriter.endElement(DIV_ELEM);
- }
-
@Override
protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component)
throws IOException {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-30 23:45:12 UTC (rev 20853)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2010-12-31 07:39:15 UTC (rev 20854)
@@ -23,39 +23,22 @@
package org.richfaces.renderkit.html;
-import static org.richfaces.renderkit.HtmlConstants.ALT_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.CLASS_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.DIV_ELEM;
-import static org.richfaces.renderkit.HtmlConstants.ID_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.IMG_ELEMENT;
-import static org.richfaces.renderkit.HtmlConstants.INPUT_ELEM;
-import static org.richfaces.renderkit.HtmlConstants.INPUT_TYPE_HIDDEN;
-import static org.richfaces.renderkit.HtmlConstants.NAME_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.SRC_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.STYLE_ATTRIBUTE;
-import static org.richfaces.renderkit.HtmlConstants.TABLE_ELEMENT;
-import static org.richfaces.renderkit.HtmlConstants.TBODY_ELEMENT;
-import static org.richfaces.renderkit.HtmlConstants.TD_ELEM;
-import static org.richfaces.renderkit.HtmlConstants.TR_ELEMENT;
-import static org.richfaces.renderkit.HtmlConstants.TYPE_ATTR;
-import static org.richfaces.renderkit.HtmlConstants.VALUE_ATTRIBUTE;
-import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
-import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractPanelMenuGroup;
+import org.richfaces.component.AbstractPanelMenuItem;
+import org.richfaces.component.html.HtmlPanelMenuGroup;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
+import static org.richfaces.renderkit.HtmlConstants.*;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
-import org.ajax4jsf.javascript.JSObject;
-import org.richfaces.component.AbstractPanelMenuGroup;
-import org.richfaces.component.AbstractPanelMenuItem;
-import org.richfaces.component.html.HtmlPanelMenuGroup;
-import org.richfaces.renderkit.RenderKitUtils;
-
/**
* @author akolonitsky
* @since 2010-10-25
@@ -73,6 +56,36 @@
//TODO nick - shouldn't this be rf-pm-gr-top?
private static final String TOP_CSS_CLASS_PREFIX = "rf-pm-top-gr";
+ private static class HeaderRenderer extends TableIconsRendererHelper {
+
+ public HeaderRenderer(String cssClassPrefix) {
+ super("label", cssClassPrefix);
+ }
+
+ protected void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ HtmlPanelMenuGroup group = (HtmlPanelMenuGroup) component;
+
+ String iconCollapsed = group.isDisabled() ? group.getIconLeftDisabled() : group.getIconLeftCollapsed();
+ String iconExpanded = group.isDisabled() ? group.getIconLeftDisabled() : group.getIconLeftExpanded();
+
+ encodeTdIcon(writer, context, cssClassPrefix + "-ico", group.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ protected void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ HtmlPanelMenuGroup group = (HtmlPanelMenuGroup) component;
+
+ String iconCollapsed = group.isDisabled() ? group.getIconRightDisabled() : group.getIconRightCollapsed();
+ String iconExpanded = group.isDisabled() ? group.getIconRightDisabled() : group.getIconRightExpanded();
+
+ //TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
+ encodeTdIcon(writer, context, cssClassPrefix + "-exp-ico", group.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ }
+
+ private final TableIconsRendererHelper headerRenderer = new HeaderRenderer(CSS_CLASS_PREFIX);
+ private final TableIconsRendererHelper topHeaderRenderer = new HeaderRenderer(TOP_CSS_CLASS_PREFIX);
+
@Override
protected void doDecode(FacesContext context, UIComponent component) {
AbstractPanelMenuGroup menuGroup = (AbstractPanelMenuGroup) component;
@@ -120,105 +133,12 @@
writer.startElement(DIV_ELEM, null);
writer.writeAttribute(ID_ATTRIBUTE, menuGroup.getClientId(context) + ":hdr", null);
writer.writeAttribute(CLASS_ATTRIBUTE, getCssClass(menuGroup, "-hdr"), null);
- encodeHeaderGroup(writer, context, menuGroup, getCssClass(menuGroup, ""));
- writer.endElement(DIV_ELEM);
- }
- private void encodeHeaderGroup(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
- writer.startElement(TABLE_ELEMENT, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-gr", null);
- writer.startElement(TBODY_ELEMENT, null);
- writer.startElement(TR_ELEMENT, null);
+ (menuGroup.isTopItem() ? topHeaderRenderer : headerRenderer).encodeHeader(writer, context, menuGroup);
- encodeHeaderGroupIconLeft(writer, context, menuItem, classPrefix);
-
- writer.startElement(TD_ELEM, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-lbl", null);
-
- UIComponent headerFacet = menuItem.getFacet("label");
- if (headerFacet != null && headerFacet.isRendered()) {
- headerFacet.encodeAll(context);
- } else {
- Object label = menuItem.getLabel();
- if (label != null && !label.equals("")) {
- writer.writeText(label, null);
- }
- }
-
- writer.endElement(TD_ELEM);
-
- encodeHeaderGroupIconRight(writer, context, menuItem, classPrefix);
-
- writer.endElement(TR_ELEMENT);
- writer.endElement(TBODY_ELEMENT);
- writer.endElement(TABLE_ELEMENT);
- }
-
- private void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuGroup, String classPrefix) throws IOException {
- String iconCollapsed = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftCollapsed();
- String iconExpanded = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftExpanded();
-
- encodeTdIcon(writer, context, classPrefix + "-ico", menuGroup.isExpanded(), iconCollapsed, iconExpanded);
- }
-
- private void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
- String iconCollapsed = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightCollapsed();
- String iconExpanded = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightExpanded();
-
- //TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
- encodeTdIcon(writer, context, classPrefix + "-exp-ico", menuItem.isExpanded(), iconCollapsed, iconExpanded);
- }
-
- private void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
- writer.startElement(TD_ELEM, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, cssClass, null);
-
- encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, "rf-pm-ico-colps");
- encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, "rf-pm-ico-exp");
-
- writer.endElement(TD_ELEM);
- }
-
- private void encodeIdIcon(ResponseWriter writer, FacesContext context, boolean isExpanded, String attrIconValue, String styleClass) throws IOException {
- if (attrIconValue == null || attrIconValue.trim().length() <= 0) {
- encodeDivIcon(writer, isExpanded, PanelMenuIcons.none, styleClass);
- } else {
- PanelMenuIcons icon = getIcon(attrIconValue);
- if (icon != null) {
- encodeDivIcon(writer, isExpanded, icon, styleClass);
- } else {
- encodeImage(writer, context, attrIconValue);
- }
- }
- }
-
- private PanelMenuIcons getIcon(String attrIconCollapsedValue) {
- if (attrIconCollapsedValue == null) {
- return null;
- }
-
- try {
- return PanelMenuIcons.valueOf(attrIconCollapsedValue);
- } catch (IllegalArgumentException e) {
- return null;
- }
- }
-
- private void encodeDivIcon(ResponseWriter writer, boolean isDisplay, PanelMenuIcons icon, String styleClass) throws IOException {
- writer.startElement(DIV_ELEM, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, concatClasses(styleClass, icon.cssClass()), null);
- writer.writeAttribute(STYLE_ATTRIBUTE, styleElement("display", isDisplay ? "none" : "block"), null);
writer.endElement(DIV_ELEM);
}
- private void encodeImage(ResponseWriter writer, FacesContext context, String attrIconValue) throws IOException {
- writer.startElement(IMG_ELEMENT, null);
- writer.writeAttribute(ALT_ATTRIBUTE, "", null);
- writer.writeURIAttribute(SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(attrIconValue, context), null);
- writer.endElement(IMG_ELEMENT);
- }
-
-
public String getCssClass(AbstractPanelMenuItem item, String postfix) {
return (item.isTopItem() ? TOP_CSS_CLASS_PREFIX : CSS_CLASS_PREFIX) + postfix;
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-30 23:45:12 UTC (rev 20853)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-31 07:39:15 UTC (rev 20854)
@@ -1,6 +1,5 @@
package org.richfaces.renderkit.html;
-import org.richfaces.component.html.HtmlPanelMenuGroup;
import org.richfaces.renderkit.RenderKitUtils;
import javax.faces.component.UIComponent;
@@ -12,24 +11,32 @@
import static org.richfaces.renderkit.HtmlConstants.*;
import static org.richfaces.renderkit.html.DivPanelRenderer.styleElement;
-public class TableIconsRendererHelper {
+public abstract class TableIconsRendererHelper {
- public void encodeHeaderGroup(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ protected final String text;
+ protected final String cssClassPrefix;
+
+ public TableIconsRendererHelper(String text, String cssClassPrefix) {
+ this.text = text;
+ this.cssClassPrefix = cssClassPrefix;
+ }
+
+ public void encodeHeader(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
writer.startElement(TABLE_ELEMENT, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-gr", null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, cssClassPrefix + "-gr", null);
writer.startElement(TBODY_ELEMENT, null);
writer.startElement(TR_ELEMENT, null);
- encodeHeaderGroupIconLeft(writer, context, menuItem, classPrefix);
+ encodeHeaderGroupIconLeft(writer, context, component);
writer.startElement(TD_ELEM, null);
- writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-lbl", null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, cssClassPrefix + "-lbl", null);
- UIComponent headerFacet = menuItem.getFacet("label");
+ UIComponent headerFacet = component.getFacet(text);
if (headerFacet != null && headerFacet.isRendered()) {
headerFacet.encodeAll(context);
} else {
- Object label = menuItem.getLabel();
+ Object label = component.getAttributes().get(text);
if (label != null && !label.equals("")) {
writer.writeText(label, null);
}
@@ -37,39 +44,28 @@
writer.endElement(TD_ELEM);
- encodeHeaderGroupIconRight(writer, context, menuItem, classPrefix);
+ encodeHeaderGroupIconRight(writer, context, component);
writer.endElement(TR_ELEMENT);
writer.endElement(TBODY_ELEMENT);
writer.endElement(TABLE_ELEMENT);
}
- public void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuGroup, String classPrefix) throws IOException {
- String iconCollapsed = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftCollapsed();
- String iconExpanded = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftExpanded();
+ protected abstract void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException;
- encodeTdIcon(writer, context, classPrefix + "-ico", menuGroup.isExpanded(), iconCollapsed, iconExpanded);
- }
+ protected abstract void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, UIComponent menuItem) throws IOException;
- public void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
- String iconCollapsed = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightCollapsed();
- String iconExpanded = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightExpanded();
-
- //TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
- encodeTdIcon(writer, context, classPrefix + "-exp-ico", menuItem.isExpanded(), iconCollapsed, iconExpanded);
- }
-
- public void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
+ protected void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
writer.startElement(TD_ELEM, null);
writer.writeAttribute(CLASS_ATTRIBUTE, cssClass, null);
- encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, "rf-pm-ico-colps");
- encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, "rf-pm-ico-exp");
+ encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, cssClassPrefix + "-colps");
+ encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, cssClassPrefix + "-exp");
writer.endElement(TD_ELEM);
}
- public void encodeIdIcon(ResponseWriter writer, FacesContext context, boolean isExpanded, String attrIconValue, String styleClass) throws IOException {
+ protected void encodeIdIcon(ResponseWriter writer, FacesContext context, boolean isExpanded, String attrIconValue, String styleClass) throws IOException {
if (attrIconValue == null || attrIconValue.trim().length() <= 0) {
encodeDivIcon(writer, isExpanded, PanelMenuIcons.none, styleClass);
} else {
@@ -82,7 +78,7 @@
}
}
- public PanelMenuIcons getIcon(String attrIconCollapsedValue) {
+ protected PanelMenuIcons getIcon(String attrIconCollapsedValue) {
if (attrIconCollapsedValue == null) {
return null;
}
@@ -94,19 +90,17 @@
}
}
- public void encodeDivIcon(ResponseWriter writer, boolean isDisplay, PanelMenuIcons icon, String styleClass) throws IOException {
+ public static void encodeDivIcon(ResponseWriter writer, boolean isDisplay, PanelMenuIcons icon, String styleClass) throws IOException {
writer.startElement(DIV_ELEM, null);
writer.writeAttribute(CLASS_ATTRIBUTE, concatClasses(styleClass, icon.cssClass()), null);
writer.writeAttribute(STYLE_ATTRIBUTE, styleElement("display", isDisplay ? "none" : "block"), null);
writer.endElement(DIV_ELEM);
}
- public void encodeImage(ResponseWriter writer, FacesContext context, String attrIconValue) throws IOException {
+ public static void encodeImage(ResponseWriter writer, FacesContext context, String attrIconValue) throws IOException {
writer.startElement(IMG_ELEMENT, null);
writer.writeAttribute(ALT_ATTRIBUTE, "", null);
writer.writeURIAttribute(SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(attrIconValue, context), null);
writer.endElement(IMG_ELEMENT);
}
-
-
}
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-30 23:45:12 UTC (rev 20853)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuGroupRendererTest.java 2010-12-31 07:39:15 UTC (rev 20854)
@@ -37,6 +37,7 @@
* @author akolonitsky
* @since 2010-10-25
*/
+@Ignore
public class PanelMenuGroupRendererTest extends RendererTestBase {
@Test
14 years
JBoss Rich Faces SVN: r20853 - in branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk: model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-30 18:45:12 -0500 (Thu, 30 Dec 2010)
New Revision: 20853
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
Log:
CODING IN PROGRESS - issue RF-9323: CDK annotation @RendererSpecificComponent.attributes doesn't work
https://issues.jboss.org/browse/RF-9323
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-30 23:14:04 UTC (rev 20852)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-30 23:45:12 UTC (rev 20853)
@@ -158,12 +158,16 @@
if (result.containsKey(propertyName)) {
// Merge property with existed one.
AptBeanProperty beanProperty = result.get(propertyName);
+ checkPropertyType(type, propertyName, propertyType, beanProperty);
if (null != (setter?beanProperty.setter:beanProperty.getter)) {
log.warn("Two " + (setter ? "setter" : "getter") + " methods for the same bean property "
+ propertyName + " in the class " + type.getQualifiedName());
+ if(!method.getModifiers().contains(Modifier.ABSTRACT)){
+ beanProperty.setAccessMethod(method, setter);
+ }
+ } else {
+ beanProperty.setAccessMethod(method, setter);
}
- checkPropertyType(type, propertyName, propertyType, beanProperty);
- beanProperty.setAccessMethod(method, setter);
} else {
AptBeanProperty beanProperty = new AptBeanProperty(propertyName);
beanProperty.setAccessMethod(method, setter);
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-12-30 23:14:04 UTC (rev 20852)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-12-30 23:45:12 UTC (rev 20853)
@@ -52,6 +52,18 @@
.put(double.class.getName(), Double.class.getName())
.build();
+ private static final ImmutableMap<String, String> DEFAULT_VALUES =
+ ImmutableMap.<String, String>builder()
+ .put(boolean.class.getName(), "Boolean.FALSE")
+ .put(byte.class.getName(), "Byte.MIN_VALUE")
+ .put(char.class.getName(), "Character.MIN_VALUE")
+ .put(short.class.getName(), "Short.MIN_VALUE")
+ .put(int.class.getName(), "Integer.MIN_VALUE")
+ .put(long.class.getName(), "Long.MIN_VALUE")
+ .put(float.class.getName(), "Float.MIN_VALUE")
+ .put(double.class.getName(), "Double.MIN_VALUE")
+ .build();
+
private final String boxingClassName;
private final String fullName;
@@ -196,6 +208,9 @@
return primitive;
}
+ public String getDefaultValue(){
+ return DEFAULT_VALUES.get(name);
+ }
/**
* <p class="changed_added_4_0">
* </p>
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-30 23:14:04 UTC (rev 20852)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-30 23:45:12 UTC (rev 20853)
@@ -51,7 +51,6 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.model.ModelElement;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
@@ -60,6 +59,7 @@
import org.richfaces.cdk.util.Strings;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
@@ -198,6 +198,8 @@
public static final ClassName DEFAULT_VALIDATOR_HANDLER = new ClassName(ValidatorHandler.class);
public static final ClassName DEFAULT_CONVERTER_HANDLER = new ClassName(ConverterHandler.class);
public static final ClassName DEFAULT_BEHAVIOR_HANDLER = new ClassName(BehaviorHandler.class);
+ public static final ImmutableSet<String> SPECIAL_PROPERTIES = ImmutableSet.of("eventNames", "defaultEventName",
+ "clientBehaviors", "family");
@Inject
private Logger log;
@@ -279,7 +281,7 @@
}
// Verify tags. If we have renderer-specific component, it should have a tag ?
for (ComponentModel component : library.getComponents()) {
- if(null != component.getRendererType() && component.getTags().isEmpty()){
+ if (null != component.getRendererType() && component.getTags().isEmpty()) {
TagModel tag = new TagModel();
verifyTag(tag, component.getId(), DEFAULT_COMPONENT_HANDLER);
component.getTags().add(tag);
@@ -361,8 +363,7 @@
if (null != component.getBaseClass()) {
try {
// Step one, lookup for parent.
- ComponentModel parentComponent =
- findParent(library.getComponents(), component);
+ ComponentModel parentComponent = findParent(library.getComponents(), component);
// To be sure what all properties for parent component were propagated.
verifyComponentAttributes(library, parentComponent, verified);
for (PropertyBase parentAttribute : parentComponent.getAttributes()) {
@@ -392,7 +393,8 @@
}
}
- private <T extends FacesComponent> T findParent(Iterable<T> components, final T component) throws NoSuchElementException {
+ private <T extends FacesComponent> T findParent(Iterable<T> components, final T component)
+ throws NoSuchElementException {
return Iterables.find(components, new Predicate<T>() {
@Override
@@ -407,7 +409,7 @@
String defaultTagName = namingConventions.inferTagName(id);
tag.setName(defaultTagName);
}
- if(null == tag.getType()){
+ if (null == tag.getType()) {
tag.setType(TagType.Facelets);
}
if (tag.isGenerate()) {
@@ -483,8 +485,8 @@
return true;
}
- protected void verifyAttribute(PropertyBase attribute, FacesComponent component) {
- // Check name.
+ protected void verifyAttribute(PropertyBase attribute, FacesComponent component) {
+ // Check name.
if (Strings.isEmpty(attribute.getName())) {
log.error("No name for attribute " + attribute);
return;
@@ -498,6 +500,10 @@
if (null == attribute.getType()) {
log.error("Unknown type of attribute [" + attribute.getName() + "]");
return;
+ }
+ if(attribute.getType().isPrimitive() && null == attribute.getDefaultValue()){
+ // Set default value for primitive
+ attribute.setDefaultValue(attribute.getType().getDefaultValue());
}
// Check binding properties.
if ("javax.faces.el.MethodBinding".equals(attribute.getType().getName())) {
@@ -514,9 +520,12 @@
// TODO Attribute should be only generated if it does not exist or abstract in the base class.
// Step one - check base class
SourceUtils sourceUtils = sourceUtilsProvider.get();
- if(null == attribute.getGenerate()){
- if(sourceUtils.isClassExists(component.getBaseClass())){
- attribute.setGenerate(!sourceUtils.getBeanProperty(component.getBaseClass(), attribute.getName()).isExists());
+ if (SPECIAL_PROPERTIES.contains(attribute.getName())) {
+ attribute.setGenerate(false);
+ } else if (null == attribute.getGenerate()) {
+ if (sourceUtils.isClassExists(component.getBaseClass())) {
+ attribute.setGenerate(!sourceUtils.getBeanProperty(component.getBaseClass(), attribute.getName())
+ .isExists());
} else {
attribute.setGenerate(true);
}
14 years
JBoss Rich Faces SVN: r20852 - branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-30 18:14:04 -0500 (Thu, 30 Dec 2010)
New Revision: 20852
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
Log:
CODING IN PROGRESS - issue RF-9323: CDK annotation @RendererSpecificComponent.attributes doesn't work
https://issues.jboss.org/browse/RF-9323
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-30 20:35:22 UTC (rev 20851)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-30 23:14:04 UTC (rev 20852)
@@ -483,8 +483,8 @@
return true;
}
- protected void verifyAttribute(PropertyBase attribute, FacesComponent component) {
- // Check name.
+ protected void verifyAttribute(PropertyBase attribute, FacesComponent component) {
+ // Check name.
if (Strings.isEmpty(attribute.getName())) {
log.error("No name for attribute " + attribute);
return;
@@ -513,6 +513,14 @@
if (Boolean.TRUE.equals(component.getGenerate())) {
// TODO Attribute should be only generated if it does not exist or abstract in the base class.
// Step one - check base class
+ SourceUtils sourceUtils = sourceUtilsProvider.get();
+ if(null == attribute.getGenerate()){
+ if(sourceUtils.isClassExists(component.getBaseClass())){
+ attribute.setGenerate(!sourceUtils.getBeanProperty(component.getBaseClass(), attribute.getName()).isExists());
+ } else {
+ attribute.setGenerate(true);
+ }
+ }
} else {
attribute.setGenerate(false);
}
14 years
JBoss Rich Faces SVN: r20851 - trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-30 15:35:22 -0500 (Thu, 30 Dec 2010)
New Revision: 20851
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
Log:
https://issues.jboss.org/browse/RF-10108 Drop down menu: client api
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2010-12-30 20:33:33 UTC (rev 20850)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2010-12-30 20:35:22 UTC (rev 20851)
@@ -43,7 +43,7 @@
this.selectedGroup = null;
rf.Event.bindById(this.id, this.options.showEvent, $.proxy(
this.___showHandler, this), this);
- rf.Event.bindById(this.id, "mouseover", $.proxy(this.__overHandler,
+ rf.Event.bindById(this.id, "mouseenter", $.proxy(this.__overHandler,
this), this);
rf.Event.bindById(this.id, "mouseleave", $.proxy(this.__leaveHandler,
this), this);
@@ -87,10 +87,10 @@
submitForm : function(item) {
var form = this.__getParentForm(item);
if (this.options.mode == "server") {
- // rf.submitForm(form, {selectedMenuItem: item.id});
+ rf.submitForm(form, {selectedMenuItem: item.id});
}
if (this.options.mode == "ajax") {
- // rf.ajax(item.id);
+ rf.ajax(item.id);
}
},
@@ -102,6 +102,11 @@
this.hide();
}
},
+
+ activateItem : function(menuItemId){
+ var item=$(RichFaces.getDomElement(menuItemId));
+ this.processItem(item);
+ },
selectItem : function(item) {
// if(item.attr('id') && !this.isDisabled(item)){
@@ -124,14 +129,14 @@
},
show: function() {
- this.menuManager.shutdownMenu();
+ this.menuManager.shutdownMenu();
+ this.menuManager.addMenuId(this.id);
this.__showPopup();
- this.menuManager.addMenuId(this.id);
},
hide: function() {
+ this.__hidePopup();
this.menuManager.deletedMenuId();
- this.__hidePopup();
},
__showPopup : function() {
14 years
JBoss Rich Faces SVN: r20850 - in trunk/ui/output/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-30 15:33:33 -0500 (Thu, 30 Dec 2010)
New Revision: 20850
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java
trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml
Log:
https://issues.jboss.org/browse/RF-10109 Drop down menu: directions
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java 2010-12-30 18:21:18 UTC (rev 20849)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java 2010-12-30 20:33:33 UTC (rev 20850)
@@ -37,12 +37,13 @@
@Attribute(defaultValue = "250")
public abstract int getPopupWith();
-// @Attribute(defaultValue = "auto")
-// public abstract String getJointPoint();
-//
-// @Attribute(defaultValue = "auto")
-// public abstract String getDirection();
+ //TODO is it correct or cdk issue
+ @Attribute(defaultValue = "org.richfaces.component.Positioning.DEFAULT")
+ public abstract Positioning getJointPoint();
+ @Attribute(defaultValue = "org.richfaces.component.Positioning.DEFAULT")
+ public abstract Positioning getDirection();
+
@Attribute(events = @EventName("groupshow"))
public abstract String getOngroupshow();
Modified: trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml 2010-12-30 18:21:18 UTC (rev 20849)
+++ trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml 2010-12-30 20:33:33 UTC (rev 20850)
@@ -47,8 +47,11 @@
</div>
</div>
</div>
+
<script type="text/javascript">
<cdk:scriptObject name="options">
+ <cdk:call expression='addToScriptHash(options, "direction", ((org.richfaces.component.Positioning)component.getAttributes().get("direction")).getValue())' />
+ <cdk:call expression='addToScriptHash(options, "jointPoint", ((org.richfaces.component.Positioning)component.getAttributes().get("jointPoint")).getValue())' />
<cdk:scriptOption attributes="hideDelay showDelay popupWith mode" />
<cdk:scriptOption attributes="onshow onhide ongroupshow ongrouphide onitemclick" wrapper="eventHandler"/>
</cdk:scriptObject>
14 years