summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/components
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2014-05-16 11:41:42 +0300
committerHenri Sara <hesara@vaadin.com>2014-05-16 13:03:09 +0300
commitb4180f2388a6ec97c422097f16da617114aba590 (patch)
tree86d73cb261f89d7360d5810e2986a6e78e066374 /server/src/com/vaadin/ui/components
parente65231e6028892bd6847777c5bad982b73278b14 (diff)
parent0f74fdff68cef4eac27913bb4fd0943ff39ca604 (diff)
downloadvaadin-framework-7.3.0.alpha2.tar.gz
vaadin-framework-7.3.0.alpha2.zip
Merge master into valo7.3.0.alpha2
This change does not include all release notes updates from master. Change-Id: I209dc06d03d4541ac33746d1161630f0ca8ae5d9
Diffstat (limited to 'server/src/com/vaadin/ui/components')
-rw-r--r--server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java6
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java2
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorChangeListener.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java80
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorSelector.java4
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java4
27 files changed, 96 insertions, 58 deletions
diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java
index 1f012157b5..dfb59e148b 100644
--- a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java
+++ b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java
index 1904d69898..f01b465dd2 100644
--- a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java
+++ b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java
index b78fda3136..18b98e1f6c 100644
--- a/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java
+++ b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java b/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java
index 1a3ef67377..3ea6c4d8f4 100644
--- a/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java
+++ b/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
index 37ea255d27..7c19395df2 100644
--- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -224,8 +224,8 @@ public class ContainerEventProvider implements CalendarEditableEventProvider,
}
if (styleNameProperty != null
&& item.getItemPropertyIds().contains(styleNameProperty)) {
- basicEvent.setDescription(String.valueOf(item.getItemProperty(
- descriptionProperty).getValue()));
+ basicEvent.setStyleName(String.valueOf(item.getItemProperty(
+ styleNameProperty).getValue()));
}
event = basicEvent;
}
diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java
index 3f14145f0c..a1ccad2712 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java
index b2b74a5e52..9fa6baadad 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java
index 13e84df666..920600368e 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java
index 531ee72c7f..2ad8c777ff 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java
index fefb2ca9b6..35719a13f3 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java b/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java
index e8a27ad50f..df708697b8 100644
--- a/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java
+++ b/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
index 65e9c94dec..f4d47f89d4 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java
index ac2470e008..8d366ed52f 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java
index ae4c5fcc12..418e03d24a 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java
index ee7fc27360..6141c84c5b 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
index e36c9e5756..96c3c097dc 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java
index 846fd7dd53..c52d0a5a82 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java b/server/src/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java
index 7ce5a7fd7e..b55b55357f 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -40,4 +40,4 @@ public class ColorChangeEvent extends Event {
public Color getColor() {
return color;
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorChangeListener.java b/server/src/com/vaadin/ui/components/colorpicker/ColorChangeListener.java
index 7afbde5028..6db148989c 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorChangeListener.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorChangeListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -39,4 +39,4 @@ public interface ColorChangeListener extends Serializable {
*/
void colorChanged(ColorChangeEvent event);
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index 5ff166b201..6147fcdd96 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -137,4 +137,4 @@ public class ColorPickerGradient extends AbstractComponent implements
protected ColorPickerGradientState getState() {
return (ColorPickerGradientState) super.getState();
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
index 9123245033..002f36d99d 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -254,4 +254,4 @@ public class ColorPickerGrid extends AbstractComponent implements ColorSelector
protected ColorPickerGridState getState() {
return (ColorPickerGridState) super.getState();
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
index de8c5db195..a3297a282c 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -214,4 +214,4 @@ public class ColorPickerHistory extends CustomComponent implements
public void colorChanged(ColorChangeEvent event) {
fireEvent(new ColorChangeEvent(this, event.getColor()));
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index 9774211bea..e7b412f7eb 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -776,4 +776,4 @@ public class ColorPickerPopup extends Window implements ClickListener,
public static Logger getLogger() {
return Logger.getLogger(ColorPickerPopup.class.getName());
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index 45c6dc76c3..ae00b267ce 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -19,7 +19,6 @@ import java.lang.reflect.Method;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.validator.RegexpValidator;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
@@ -67,13 +66,12 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
this.color = color;
field = new TextField();
- field.setReadOnly(true);
field.setImmediate(true);
field.setSizeFull();
field.setStyleName("v-colorpicker-preview-textfield");
field.setData(this);
field.addValueChangeListener(this);
- field.addValidator(new RegexpValidator("#[0-9a-fA-F]{6}", true, ""));
+
addComponent(field);
setColor(color);
@@ -85,7 +83,6 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
// Unregister listener
field.removeValueChangeListener(this);
- field.setReadOnly(false);
String colorCSS = color.getCSS();
field.setValue(colorCSS);
@@ -97,7 +94,6 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
}
// Re-register listener
- field.setReadOnly(true);
field.addValueChangeListener(this);
// Set the text color
@@ -130,21 +126,63 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
@Override
public void valueChange(ValueChangeEvent event) {
String value = (String) event.getProperty().getValue();
-
- if (!field.isValid()) {
+ try {
+ if (value != null) {
+ /*
+ * Description of supported formats see
+ * http://www.w3schools.com/cssref/css_colors_legal.asp
+ */
+ if (value.length() == 7 && value.startsWith("#")) {
+ // CSS color format (e.g. #000000)
+ int red = Integer.parseInt(value.substring(1, 3), 16);
+ int green = Integer.parseInt(value.substring(3, 5), 16);
+ int blue = Integer.parseInt(value.substring(5, 7), 16);
+ color = new Color(red, green, blue);
+
+ } else if (value.startsWith("rgb")) {
+ // RGB color format rgb/rgba(255,255,255,0.1)
+ String[] colors = value.substring(value.indexOf("(") + 1,
+ value.length() - 1).split(",");
+
+ int red = Integer.parseInt(colors[0]);
+ int green = Integer.parseInt(colors[1]);
+ int blue = Integer.parseInt(colors[2]);
+ if (colors.length > 3) {
+ int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
+ color = new Color(red, green, blue, alpha);
+ } else {
+ color = new Color(red, green, blue);
+ }
+
+ } else if (value.startsWith("hsl")) {
+ // HSL color format hsl/hsla(100,50%,50%,1.0)
+ String[] colors = value.substring(value.indexOf("(") + 1,
+ value.length() - 1).split(",");
+
+ int hue = Integer.parseInt(colors[0]);
+ int saturation = Integer.parseInt(colors[1]
+ .replace("%", ""));
+ int lightness = Integer
+ .parseInt(colors[2].replace("%", ""));
+ int rgb = Color.HSLtoRGB(hue, saturation, lightness);
+
+ if (colors.length > 3) {
+ int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
+ color = new Color(rgb);
+ color.setAlpha(alpha);
+ } else {
+ color = new Color(rgb);
+ }
+ }
+
+ oldValue = value;
+ fireEvent(new ColorChangeEvent((Component) field.getData(),
+ color));
+ }
+
+ } catch (NumberFormatException nfe) {
+ // Revert value
field.setValue(oldValue);
- return;
- } else {
- oldValue = value;
- }
-
- if (value != null && value.length() == 7) {
- int red = Integer.parseInt(value.substring(1, 3), 16);
- int green = Integer.parseInt(value.substring(3, 5), 16);
- int blue = Integer.parseInt(value.substring(5, 7), 16);
- color = new Color(red, green, blue);
-
- fireEvent(new ColorChangeEvent((Component) field.getData(), color));
}
}
@@ -155,4 +193,4 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
protected String getCss(Component c) {
return "background: " + color.getCSS();
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
index 263349c17c..8e441b25ee 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -230,4 +230,4 @@ public class ColorPickerSelect extends CustomComponent implements
grid.setColorGrid(createColors(new Color(0, 0, 0xFF), 14, 10));
}
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorSelector.java b/server/src/com/vaadin/ui/components/colorpicker/ColorSelector.java
index 31ce2b2e5b..c282c22f62 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorSelector.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorSelector.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -40,4 +40,4 @@ public interface ColorSelector extends Serializable, HasColorChangeListener {
* @return the color
*/
public Color getColor();
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java b/server/src/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
index c84a90bf6f..eb16d8cbbe 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -33,4 +33,4 @@ public interface HasColorChangeListener extends Serializable {
*/
void removeColorChangeListener(ColorChangeListener listener);
-} \ No newline at end of file
+}