Author: nbelaevski
Date: 2007-11-15 13:03:04 -0500 (Thu, 15 Nov 2007)
New Revision: 4022
Removed:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/ArrayUtil.java
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
Log:
Some enhancements for orderingList
Deleted:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/ArrayUtil.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/ArrayUtil.java 2007-11-15
17:45:40 UTC (rev 4021)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/ArrayUtil.java 2007-11-15
18:03:04 UTC (rev 4022)
@@ -1,83 +0,0 @@
-/**
- *
- */
-package org.richfaces.component;
-
-
-/**
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 05.11.2007
- *
- * @since 3.2
- */
-class ArrayUtil {
-
- final static void copy(Object out, Object in, int[] indexes) {
- if (in instanceof int[]) {
- copy((int[])out, (int[])in, indexes);
- } else if (in instanceof short[]) {
- copy((short[])out, (short[])in, indexes);
- } else if (in instanceof byte[]) {
- copy((byte[])out, (byte[])in, indexes);
- } else if (in instanceof boolean[]) {
- copy((boolean[])out, (boolean[])in, indexes);
- } else if (in instanceof char[]) {
- copy((char[])out, (char[])in, indexes);
- } else if (in instanceof float[]) {
- copy((float[])out, (float[])in, indexes);
- } else if (in instanceof double[]) {
- copy((double[])out, (double[])in, indexes);
- } else if (in instanceof long[]) {
- copy((long[])out, (long[])in, indexes);
- } else {
- copy((Object[])out, (Object[])in, indexes);
- }
- }
-
- final static void copy(Object[] out, Object[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(int[] out, int[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(short[] out, short[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(byte[] out, byte[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(boolean[] out, boolean[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(char[] out, char[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(float[] out, float[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(double[] out, double[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
- final static void copy(long[] out, long[] in, int[] indexes) {
- for (int i = 0; i < indexes.length; i++) {
- out[i] = in[indexes[i]];
- }
- }
-}
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-15
17:45:40 UTC (rev 4021)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-15
18:03:04 UTC (rev 4022)
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -829,10 +830,15 @@
}
convertedValue = arrayList;
} else {
- convertedValue = Array.newInstance(savedValue.getClass().getComponentType(),
+ Object[] savedValueArray = (Object[]) savedValue;
+ Object[] convertedValueArray = (Object[])
Array.newInstance(savedValue.getClass().getComponentType(),
Array.getLength(savedValue));
- ArrayUtil.copy(convertedValue,
- savedValue, indexes);
+
+ convertedValue = convertedValueArray;
+
+ for (int i = 0; i < indexes.length; i++) {
+ convertedValueArray[i] = savedValueArray[indexes[i]];
+ }
}
//submittedValueHolder.newValue = convertedValue;
@@ -956,7 +962,11 @@
} else if (value == null) {
return (true);
} else {
- return (!(previous.equals(value)));
+ if (previous instanceof Object[]) {
+ return !Arrays.equals((Object[]) previous, (Object[]) value);
+ } else {
+ return (!(previous.equals(value)));
+ }
}
}
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-15
17:45:40 UTC (rev 4021)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-15
18:03:04 UTC (rev 4022)
@@ -5,10 +5,14 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -25,6 +29,8 @@
public abstract class OrderingListRendererBase extends AbstractRowsRenderer {
+ private static final String MESSAGE_BUNDLE_NAME =
OrderingListRendererBase.class.getPackage().getName() + "OrderingList";
+
private final static Character ACTIVITY_MARKER = 'a';
private final static Character SELECTION_MARKER = 's';
@@ -96,7 +102,7 @@
protected static abstract class ControlsHelper {
private String name;
- private String text;
+ private String bundlePropertyName;
private String imageURI;
@@ -113,15 +119,18 @@
private String buttonStyle;
private boolean enable;
+
+ private String defaultText;
public abstract boolean isRendered(FacesContext context, UIOrderingList list);
- public ControlsHelper(String name, String text, String imageURI,
+ public ControlsHelper(String name, String bundlePropertyName, String defaultText,
String imageURI,
String facetName, String styleClassName, String styleFromAttribute, String
buttonStyle,
String idSuffix, String customEvent, boolean isEnable) {
super();
this.name = name;
- this.text = text;
+ this.bundlePropertyName = bundlePropertyName;
+ this.defaultText = defaultText;
this.imageURI = imageURI;
this.facetName = facetName;
this.styleClassName = styleClassName;
@@ -136,8 +145,8 @@
return name;
}
- public String getText() {
- return text;
+ public String getBundlePropertyName() {
+ return bundlePropertyName;
}
public String getImageURI() {
@@ -171,10 +180,14 @@
public boolean isEnable() {
return enable;
}
+
+ public String getDefaultText() {
+ return defaultText;
+ }
};
protected static final ControlsHelper[] HELPERS = new ControlsHelper[] {
- new ControlsHelper("top", "↟",
OrderingListIconTop.class.getName(), FACET_TOP,
+ new ControlsHelper("top", "TOP_LABEL", "Top",
OrderingListIconTop.class.getName(), FACET_TOP,
" rich-ordering-control-top", ATTRIBUTE_CLASS_TOP_CONTROL,
"ol_control_bn_top",
CONTROL_ID_TOP, ATTRIBUTE_CE_ONTOPCLICK, true) {
@@ -183,7 +196,7 @@
}
},
- new ControlsHelper("disabledTop", "↟",
OrderingListIconTopDisabled.class.getName(), FACET_DIS_TOP,
+ new ControlsHelper("disabledTop", "TOP_LABEL", "Top",
OrderingListIconTopDisabled.class.getName(), FACET_DIS_TOP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
"ol_control_dbn_top",
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_TOP), null, false) {
@@ -192,7 +205,7 @@
}
},
- new ControlsHelper("up", "↑",
OrderingListIconUp.class.getName(), FACET_UP,
+ new ControlsHelper("up", "UP_LABEL", "Up",
OrderingListIconUp.class.getName(), FACET_UP,
" rich-ordering-control-up", ATTRIBUTE_CLASS_UP_CONTROL,
"ol_control_bn_up",
CONTROL_ID_UP, ATTRIBUTE_CE_ONUPCLICK ,true) {
@@ -201,7 +214,7 @@
}
},
- new ControlsHelper("disabledUp", "↑",
OrderingListIconUpDisabled.class.getName(), FACET_DIS_UP,
+ new ControlsHelper("disabledUp", "UP_LABEL", "Up",
OrderingListIconUpDisabled.class.getName(), FACET_DIS_UP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
"ol_control_dbn_up",
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_UP), null, false) {
@@ -210,7 +223,7 @@
}
},
- new ControlsHelper("down", "↓",
OrderingListIconDown.class.getName(), FACET_DOWN,
+ new ControlsHelper("down", "DOWN_LABEL", "Down",
OrderingListIconDown.class.getName(), FACET_DOWN,
" rich-ordering-control-down", ATTRIBUTE_CLASS_DOWN_CONTROL,
"ol_control_bn_down",
CONTROL_ID_DOWN, ATTRIBUTE_CE_ONDOWNCLICK, true) {
@@ -219,7 +232,7 @@
}
},
- new ControlsHelper("disabledDown", "↓",
OrderingListIconDownDisabled.class.getName(), FACET_DIS_DOWN,
+ new ControlsHelper("disabledDown", "DOWN_LABEL", "Down",
OrderingListIconDownDisabled.class.getName(), FACET_DIS_DOWN,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
"ol_control_dbn_down",
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_DOWN), null, false) {
@@ -228,7 +241,7 @@
}
},
- new ControlsHelper("bottom", "↡",
OrderingListIconBottom.class.getName(), FACET_BOTTOM,
+ new ControlsHelper("bottom", "BOTTOM_LABEL", "Bottom",
OrderingListIconBottom.class.getName(), FACET_BOTTOM,
" rich-ordering-control-bottom", ATTRIBUTE_CLASS_BOTTOM_CONTROL,
"ol_control_bn_bottom",
CONTROL_ID_BOTTOM, ATTRIBUTE_CE_ONBOTTOMCLICK, true) {
@@ -237,7 +250,7 @@
}
},
- new ControlsHelper("disabledBottom", "↡",
OrderingListIconBottomDisabled.class.getName(), FACET_DIS_BOTTOM,
+ new ControlsHelper("disabledBottom", "BOTTOM_LABEL",
"Bottom", OrderingListIconBottomDisabled.class.getName(), FACET_DIS_BOTTOM,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
"ol_control_dbn_bottom",
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_BOTTOM), null, false) {
@@ -310,7 +323,24 @@
protected void encodeControlFacet(FacesContext context, UIOrderingList orderingList,
ControlsHelper helper, String clientId, ResponseWriter writer)
throws IOException {
+ Locale locale = null;
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ }
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceBundle bundle = null;
+
+ if (locale != null) {
+ try {
+ bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE_NAME, locale, contextClassLoader);
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
UIComponent facet = orderingList.getFacet(helper.getFacetName());
boolean isButton = false;
boolean useFacet = (facet != null && facet.isRendered());
@@ -336,7 +366,7 @@
//none
}
- boolean encodeDiv = useFacet || htmlElem != null;
+ boolean encodeDiv = !isButton && (useFacet || htmlElem != null);
if (encodeDiv) {
writer.startElement(HTML.DIV_ELEM, orderingList);
@@ -371,12 +401,27 @@
renderChild(context, facet);
} else {
if (isButton) {
- writer.writeAttribute("style", "font-size: 1.5em;", null);
currentStyle = helper.buttonStyle.concat(currentStyle);
//writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
if (!helper.enable) {
writer.writeAttribute(HTML.DISABLED_ATTR, "true", null);
}
+
+ String label = null;
+
+ if (bundle != null) {
+ try {
+ label = bundle.getString(helper.getBundlePropertyName());
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
+ if (label == null) {
+ label = helper.getDefaultText();
+ }
+
+ writer.writeText(label, null);
} else {
//writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
writer.startElement(HTML.IMG_ELEMENT, orderingList);
@@ -394,6 +439,11 @@
writer.endElement(htmlElem);
}
+ if (isButton) {
+ writer.startElement("br", orderingList);
+ writer.endElement("br");
+ }
+
if (encodeDiv) {
writer.endElement(HTML.DIV_ELEM);
writer.endElement(HTML.DIV_ELEM);
Modified:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-15
17:45:40 UTC (rev 4021)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-15
18:03:04 UTC (rev 4022)
@@ -122,7 +122,6 @@
<u:style name="color" skin="generalTextColor"/>
<u:style name="font-size" skin="generalSizeFont"/>
<u:style name="font-family" skin="generalFamilyFont"/>
- <u:style name="border" value="0"/>
<u:style name="white-space" value="nowrap"/>
</u:selector>
<u:selector name=".ol_control_bn_up">