sliders.setStyleName("rgb-sliders");
redSlider = createRGBSlider("Red", "red");
-
- try {
- redSlider.setValue(((Integer) color.getRed()).doubleValue());
- } catch (ValueOutOfBoundsException e) {
- }
+ greenSlider = createRGBSlider("Green", "green");
+ blueSlider = createRGBSlider("Blue", "blue");
+ setRgbSliderValues(color);
redSlider.addValueChangeListener(new ValueChangeListener() {
@Override
sliders.addComponent(redSlider);
- greenSlider = createRGBSlider("Green", "green");
-
- try {
- greenSlider.setValue(((Integer) color.getGreen()).doubleValue());
- } catch (ValueOutOfBoundsException e) {
- }
-
greenSlider.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
});
sliders.addComponent(greenSlider);
- blueSlider = createRGBSlider("Blue", "blue");
-
- try {
- blueSlider.setValue(((Integer) color.getBlue()).doubleValue());
- } catch (ValueOutOfBoundsException e) {
- }
-
blueSlider.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
hsvLayout.addComponent(hsvGradient);
selectors.add(hsvGradient);
- float[] hsv = color.getHSV();
VerticalLayout sliders = new VerticalLayout();
sliders.setStyleName("hsv-sliders");
hueSlider = new Slider("Hue", 0, 360);
- try {
- hueSlider.setValue(((Float) hsv[0]).doubleValue());
- } catch (ValueOutOfBoundsException e1) {
- }
+ saturationSlider = new Slider("Saturation", 0, 100);
+ valueSlider = new Slider("Value", 0, 100);
+
+ float[] hsv = color.getHSV();
+ setHsvSliderValues(hsv);
hueSlider.setStyleName("hsv-slider");
hueSlider.addStyleName("hue-slider");
});
sliders.addComponent(hueSlider);
- saturationSlider = new Slider("Saturation", 0, 100);
-
- try {
- saturationSlider.setValue(((Float) hsv[1]).doubleValue());
- } catch (ValueOutOfBoundsException e1) {
- }
-
saturationSlider.setStyleName("hsv-slider");
saturationSlider.setWidth("220px");
saturationSlider.setImmediate(true);
});
sliders.addComponent(saturationSlider);
- valueSlider = new Slider("Value", 0, 100);
-
- try {
- valueSlider.setValue(((Float) hsv[2]).doubleValue());
- } catch (ValueOutOfBoundsException e1) {
- }
-
valueSlider.setStyleName("hsv-slider");
valueSlider.setWidth("220px");
valueSlider.setImmediate(true);
setColor(event.getColor());
updatingColors = true;
- try {
- redSlider
- .setValue(((Integer) selectedColor.getRed()).doubleValue());
- blueSlider.setValue(((Integer) selectedColor.getBlue())
- .doubleValue());
- greenSlider.setValue(((Integer) selectedColor.getGreen())
- .doubleValue());
-
- float[] hsv = selectedColor.getHSV();
- hueSlider.setValue(((Float) (hsv[0] * 360f)).doubleValue());
- saturationSlider.setValue(((Float) (hsv[1] * 100f)).doubleValue());
- valueSlider.setValue(((Float) (hsv[2] * 100f)).doubleValue());
+ setRgbSliderValues(selectedColor);
+ float[] hsv = selectedColor.getHSV();
+ setHsvSliderValues(hsv);
- } catch (ValueOutOfBoundsException e) {
- e.printStackTrace();
- }
updatingColors = false;
for (ColorSelector s : selectors) {
}
}
+ private void setRgbSliderValues(Color color) {
+ try {
+ redSlider.setValue(((Integer) color.getRed()).doubleValue());
+ blueSlider.setValue(((Integer) color.getBlue()).doubleValue());
+ greenSlider.setValue(((Integer) color.getGreen()).doubleValue());
+ } catch (ValueOutOfBoundsException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void setHsvSliderValues(float[] hsv) {
+ try {
+ hueSlider.setValue(((Float) (hsv[0] * 360f)).doubleValue());
+ saturationSlider.setValue(((Float) (hsv[1] * 100f)).doubleValue());
+ valueSlider.setValue(((Float) (hsv[2] * 100f)).doubleValue());
+ } catch (ValueOutOfBoundsException e) {
+ e.printStackTrace();
+ }
+ }
+
@Override
public void addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>ColorPickerTest</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ColorPickerTest</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.colorpicker.ColorPickerHsvTest?restartApplication</td>
+ <td></td>
+</tr>
+<!-- verify HSV sliders when initially opening the tab, ticket #7863 -->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerHsvTest::PID_Scolorpicker/domChild[1]</td>
+ <td>20,16</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerHsvTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>16,5</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>hsv-initial-sliders</td>
+</tr>
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.colorpicker;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ColorPickerArea;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Tests the HSV tab slider values when initially opening the tab.
+ */
+public class ColorPickerHsvTest extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setContent(layout);
+
+ layout.addComponent(new Label(
+ "HSV initial values when opening the tab for the first time"));
+ ColorPickerArea colorpicker = new ColorPickerArea();
+ colorpicker.setColor(new Color(Integer.parseInt("00b4f0", 16)));
+ colorpicker.setDefaultCaptionEnabled(false);
+ colorpicker.setId("colorpicker");
+ layout.addComponent(colorpicker);
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests the slider values when initially opening the HSV tab.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7863;
+ }
+
+}