Author: konstantin.mishin
Date: 2009-07-31 12:12:54 -0400 (Fri, 31 Jul 2009)
New Revision: 15084
Modified:
branches/community/3.3.X/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java
branches/community/3.3.X/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx
Log:
RF-7627
Modified:
branches/community/3.3.X/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java
===================================================================
---
branches/community/3.3.X/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java 2009-07-31
16:12:09 UTC (rev 15083)
+++
branches/community/3.3.X/ui/colorPicker/src/main/java/org/richfaces/renderkit/ColorPickerRendererBase.java 2009-07-31
16:12:54 UTC (rev 15084)
@@ -1,19 +1,27 @@
package org.richfaces.renderkit;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import java.util.Set;
import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.richfaces.component.UIColorPicker;
import org.richfaces.component.util.MessageUtil;
public abstract class ColorPickerRendererBase extends InputRendererBase {
+ public static final String BUNDLE = ColorPickerRendererBase.class.getPackage().getName()
+ ".colorPicker";
+
public void addPopupToAjaxRendered(FacesContext context, UIColorPicker component) {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
@@ -61,4 +69,63 @@
throw new IllegalArgumentException("Illegal color value: [" + value + "]
for component " +
MessageUtil.getLabel(context, component));
}
+
+ public void initButtonLabels(FacesContext context, UIComponent component){
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this,
component);
+ Locale locale = getLocale(context);
+ ClassLoader loader = getClassLoader();
+ ResourceBundle bundleApplication = null;
+ ResourceBundle bundleExternal = null;
+ String messageBundle = context.getApplication().getMessageBundle();
+ if (messageBundle != null) {
+ bundleApplication = ResourceBundle.getBundle(messageBundle, locale,
+ loader);
+ }
+ try {
+ bundleExternal = ResourceBundle.getBundle(BUNDLE, locale, loader);
+ } catch (MissingResourceException e) {}
+ String[] names = {"Apply", "Cancel"};
+ for (String name : names) {
+ String label = null;
+ String bundleKey = "RICH_COLORPICKER_" + name.toUpperCase() +
"_LABEL";
+ if (bundleApplication != null) {
+ try {
+ label = bundleApplication.getString(bundleKey);
+ } catch (MissingResourceException mre) {
+ // Current key was not found, ignore this exception;
+ }
+ }
+ if (label == null && bundleExternal != null) {
+ try {
+ label = bundleExternal.getString(bundleKey);
+ } catch (MissingResourceException mre) {
+ // Current key was not found, ignore this exception;
+ }
+ }
+ if (label == null) {
+ label = name;
+ }
+ variables.setVariable(name, label);
+ }
+ }
+
+ private static Locale getLocale(FacesContext context) {
+ Locale locale = null;
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ }
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
+ return locale;
+ }
+
+ private static ClassLoader getClassLoader() {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ loader = ClassLoader.getSystemClassLoader();
+ }
+ return loader;
+ }
}
\ No newline at end of file
Modified:
branches/community/3.3.X/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx
===================================================================
---
branches/community/3.3.X/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx 2009-07-31
16:12:09 UTC (rev 15083)
+++
branches/community/3.3.X/ui/colorPicker/src/main/templates/org/richfaces/htmlColorPicker.jspx 2009-07-31
16:12:54 UTC (rev 15084)
@@ -27,6 +27,8 @@
<f:call name="addPopupToAjaxRendered" />
+ <f:call name="initButtonLabels" />
+
<span id="#{clientId}"
class="rich-color-picker-span" x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
<input readonly="readonly" type="text"
name="#{clientId}" value="#{value}"
size="#{component.attributes['inputSize']}"/>
<jsp:scriptlet><![CDATA[
@@ -99,8 +101,8 @@
<label for="#{clientId}-colorPicker-hsb-b">B:</label>
<input id="#{clientId}-colorPicker-hsb-b"
class="rich-color-picker-colors-input" type="text"
maxlength="3" size="2" />
</div>
- <button type="button" class="rich-color-picker-submit"
name="apply">Apply</button>
- <button type="button" class="rich-color-picker-cancel"
name="cancel">Cancel</button>
+ <button type="button" class="rich-color-picker-submit"
name="apply">#{Apply}</button>
+ <button type="button" class="rich-color-picker-cancel"
name="cancel">#{Cancel}</button>
</div>
</div>
<div style="display: none;"
id="#{clientId}-colorPicker-script">
Show replies by date