Commit 822fdfdf authored by Evan W. Patton's avatar Evan W. Patton

Detect and parse colors with different radix

Fixes #1118

Change-Id: Ib08fb391529b26ca107b5e8f67acb329e70e958e
parent ec77db59
......@@ -130,6 +130,11 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
*/
private Command showCustomPicker;
/**
* The default color value, as a numeric value.
*/
private long defaultValueArgb;
/**
* Creates a new instance of the property editor.
*
......@@ -147,14 +152,20 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
* @param colors language specific hex number prefix
* @param hexPrefix colors to be shown in property editor - must not be
* {@code null} or empty
* @oaram defaultValue the color of the default value, for display in the editor only
* @param defaultValue the color of the default value, for display in the editor only
* @param advanced specify true to show a button for the advanced picker
*/
public ColorChoicePropertyEditor(final Color[] colors, final String hexPrefix, final String defaultValue, final boolean advanced) {
this.hexPrefix = hexPrefix;
this.colors = colors;
this.advanced = advanced;
this.defaultValue = defaultValue.substring(4);
if (defaultValue.startsWith(hexPrefix)) {
this.defaultValue = defaultValue.substring(hexPrefix.length()-6); // Take last 6 digits (assumes RRGGBB format)
this.defaultValueArgb = Long.valueOf("FF" + this.defaultValue, 16) & 0xFFFFFFFFL;
} else {
this.defaultValue = defaultValue;
this.defaultValueArgb = Long.valueOf(defaultValue, 10) & 0xFFFFFFFFL;
}
// Initialize UI
List<DropDownItem> choices = Lists.newArrayList();
......@@ -253,12 +264,11 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
}
long argbValue = Long.valueOf(propertyValue, radix) & 0xFFFFFFFFL;
long defaultArgbValue = Long.valueOf("FF" + defaultValue, radix) & 0xFFFFFFFFL;
if (argbValue == defaultArgbValue || argbValue == 0) {
if (argbValue == this.defaultValueArgb || argbValue == 0) {
selectedColorMenu.setHTML(Color.getHtmlDescription(defaultValue, Ode.MESSAGES.defaultColor()));
if (advanced) {
selectedColorMenu.replaceLastItem(new DropDownItem(WIDGET_NAME, makeCustomHTML(defaultArgbValue), showCustomPicker));
setPickerColor(defaultArgbValue);
selectedColorMenu.replaceLastItem(new DropDownItem(WIDGET_NAME, makeCustomHTML(this.defaultValueArgb), showCustomPicker));
setPickerColor(this.defaultValueArgb);
}
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment