private void updateFieldType() {
   if (fieldType != null) {
     final boolean hex = fieldType.equals(ColorChooserFieldType.hex);
     setColumns(hex ? 6 : 9);
     updateText();
   }
 }
  private void updateColorFromField() {
    final String current = getText();
    if (!current.equals(last)) {
      try {
        final boolean hex = fieldType.equals(ColorChooserFieldType.hex);
        Color newColor =
            hex ? ColorUtils.parseHexColor(current) : ColorUtils.parseRgbColor(current);
        if (newColor != null) {
          // todo Ignoring alpha for now
          newColor = ColorUtils.removeAlpha(newColor);

          // Apply new value
          setColor(newColor);
        } else {
          // Restore old value
          updateViewFromColor();
        }
      } catch (final Throwable e) {
        // Restore old value
        updateViewFromColor();
      }
    }
  }
 private String getColorText(final Color color) {
   final boolean hex = fieldType.equals(ColorChooserFieldType.hex);
   return hex
       ? ColorUtils.getHexColor(color)
       : color.getRed() + "," + color.getGreen() + "," + color.getBlue();
 }