aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/ui/colorpicker/ColorPickerGradientConnector.java24
-rw-r--r--server/src/main/java/com/vaadin/data/HasValue.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractColorPicker.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java43
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeListener.java42
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java73
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java132
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java100
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java146
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java48
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java99
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorSelector.java43
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java48
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGradientState.java4
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGridState.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java2
16 files changed, 225 insertions, 602 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/colorpicker/ColorPickerGradientConnector.java b/client/src/main/java/com/vaadin/client/ui/colorpicker/ColorPickerGradientConnector.java
index c05449d7bd..a454492391 100644
--- a/client/src/main/java/com/vaadin/client/ui/colorpicker/ColorPickerGradientConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/colorpicker/ColorPickerGradientConnector.java
@@ -19,8 +19,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.communication.RpcProxy;
-import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
@@ -64,22 +64,18 @@ public class ColorPickerGradientConnector extends AbstractComponentConnector
}
@Override
- public void onStateChanged(StateChangeEvent stateChangeEvent) {
- super.onStateChanged(stateChangeEvent);
- if (stateChangeEvent.hasPropertyChanged("cursorX")
- || stateChangeEvent.hasPropertyChanged("cursorY")) {
-
- getWidget().setCursor(getState().cursorX, getState().cursorY);
- }
- if (stateChangeEvent.hasPropertyChanged("bgColor")) {
- getWidget().setBGColor(getState().bgColor);
- }
- }
-
- @Override
protected void init() {
super.init();
getWidget().addMouseUpHandler(this);
}
+ @OnStateChange({ "cursorX", "cursorY" })
+ void updateCursor() {
+ getWidget().setCursor(getState().cursorX, getState().cursorY);
+ }
+
+ @OnStateChange("bgColor")
+ void updateBgColor() {
+ getWidget().setBGColor(getState().bgColor);
+ }
}
diff --git a/server/src/main/java/com/vaadin/data/HasValue.java b/server/src/main/java/com/vaadin/data/HasValue.java
index 40e413821b..8333c8a02a 100644
--- a/server/src/main/java/com/vaadin/data/HasValue.java
+++ b/server/src/main/java/com/vaadin/data/HasValue.java
@@ -16,11 +16,13 @@
package com.vaadin.data;
import java.io.Serializable;
+import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.EventListener;
import com.vaadin.server.ClientConnector;
import com.vaadin.shared.Registration;
+import com.vaadin.util.ReflectTools;
/**
* A generic interface for field components and other user interface objects
@@ -117,6 +119,11 @@ public interface HasValue<V> extends Serializable {
public interface ValueChangeListener<V> extends
EventListener<ValueChange<V>> {
+ @Deprecated
+ public static final Method VALUE_CHANGE_METHOD = ReflectTools
+ .findMethod(ValueChangeListener.class, "accept",
+ ValueChange.class);
+
/**
* Invoked when this listener receives a value change event from an
* event source to which it has been added.
diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
index d9a668bb9a..6814a96796 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
@@ -101,13 +101,11 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
protected PopupStyle popupStyle = PopupStyle.POPUP_NORMAL;
- /** The popup window. */
private ColorPickerPopup window;
/** The currently selected color. */
protected Color color;
- /** The UI. */
private UI parent;
private String popupCaption = null;
@@ -452,10 +450,10 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
window.setImmediate(true);
window.addCloseListener(
event -> getState().popupVisible = false);
- window.addColorChangeListener(
- event -> setValue(event.getColor()));
+ window.addValueChangeListener(
+ event -> setValue(event.getValue()));
- window.getHistory().setColor(color);
+ window.getHistory().setValue(color);
window.setPositionX(positionX);
window.setPositionY(positionY);
window.setVisible(true);
@@ -471,8 +469,8 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
window.setHistoryVisible(historyVisible);
window.setPreviewVisible(textfieldVisible);
- window.setColor(color);
- window.getHistory().setColor(color);
+ window.setValue(color);
+ window.getHistory().setValue(color);
window.setVisible(true);
parent.addWindow(window);
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java
deleted file mode 100644
index aa703deb19..0000000000
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeEvent.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2000-2016 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
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui.components.colorpicker;
-
-import com.vaadin.shared.ui.colorpicker.Color;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Component.Event;
-
-/**
- * The color changed event which is passed to the listeners when a color change
- * occurs.
- *
- * @since 7.0.0
- */
-public class ColorChangeEvent extends Event {
- private final Color color;
-
- public ColorChangeEvent(Component source, Color color) {
- super(source);
-
- this.color = color;
- }
-
- /**
- * Returns the new color.
- */
- public Color getColor() {
- return color;
- }
-}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeListener.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeListener.java
deleted file mode 100644
index b234dc3d5d..0000000000
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorChangeListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2000-2016 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
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui.components.colorpicker;
-
-import java.io.Serializable;
-
-/**
- * The listener interface for receiving colorChange events. The class that is
- * interested in processing a {@link ColorChangeEvent} implements this
- * interface, and the object created with that class is registered with a
- * component using the component's <code>addColorChangeListener</code> method.
- * When the colorChange event occurs, that object's appropriate method is
- * invoked.
- *
- * @since 7.0.0
- *
- * @see ColorChangeEvent
- */
-public interface ColorChangeListener extends Serializable {
-
- /**
- * Called when a new color has been selected.
- *
- * @param event
- * An event containing information about the color change.
- */
- void colorChanged(ColorChangeEvent event);
-
-}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index 77b939e8b4..ed8b12f80b 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -15,44 +15,24 @@
*/
package com.vaadin.ui.components.colorpicker;
-import java.lang.reflect.Method;
-
-import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientState;
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
-import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
/**
* A component that represents a color gradient within a color picker.
*
* @since 7.0.0
*/
-public class ColorPickerGradient extends AbstractComponent
- implements ColorSelector {
-
- private static final Method COLOR_CHANGE_METHOD;
- static {
- try {
- COLOR_CHANGE_METHOD = ColorChangeListener.class.getDeclaredMethod(
- "colorChanged", new Class[] { ColorChangeEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in ColorPicker");
- }
- }
+public class ColorPickerGradient extends AbstractField<Color> {
private ColorPickerGradientServerRpc rpc = new ColorPickerGradientServerRpc() {
@Override
public void select(int cursorX, int cursorY) {
- x = cursorX;
- y = cursorY;
- color = converter.calculate(x, y);
-
- fireColorChanged(color);
+ setValue(converter.calculate(cursorX, cursorY), true);
}
};
@@ -62,12 +42,6 @@ public class ColorPickerGradient extends AbstractComponent
/** The foreground color. */
private Color color;
- /** The x-coordinate. */
- private int x = 0;
-
- /** The y-coordinate. */
- private int y = 0;
-
private ColorPickerGradient() {
registerRpc(rpc);
// width and height must be set here instead of in theme, otherwise
@@ -91,28 +65,16 @@ public class ColorPickerGradient extends AbstractComponent
}
@Override
- public void setColor(Color c) {
- color = c;
-
- int[] coords = converter.calculate(c);
- x = coords[0];
- y = coords[1];
-
- getState().cursorX = x;
- getState().cursorY = y;
-
- }
-
- @Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
- return () -> removeListener(ColorChangeEvent.class, listener);
+ public Color getValue() {
+ return color;
}
@Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- removeListener(ColorChangeEvent.class, listener);
+ protected void doSetValue(Color color) {
+ this.color = color;
+ int[] coords = converter.calculate(color);
+ getState().cursorX = coords[0];
+ getState().cursorY = coords[1];
}
/**
@@ -126,21 +88,6 @@ public class ColorPickerGradient extends AbstractComponent
}
@Override
- public Color getColor() {
- return color;
- }
-
- /**
- * Notifies the listeners that the color has changed
- *
- * @param color
- * The color which it changed to
- */
- public void fireColorChanged(Color color) {
- fireEvent(new ColorChangeEvent(this, color));
- }
-
- @Override
protected ColorPickerGradientState getState() {
return (ColorPickerGradientState) super.getState();
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
index 544d6c9c9e..566a24331e 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
@@ -16,52 +16,37 @@
package com.vaadin.ui.components.colorpicker;
import java.awt.Point;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGridServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerGridState;
-import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
/**
* A component that represents a color selection grid within a color picker.
*
* @since 7.0.0
*/
-public class ColorPickerGrid extends AbstractComponent
- implements ColorSelector {
+public class ColorPickerGrid extends AbstractField<Color> {
private static final String STYLENAME = "v-colorpicker-grid";
- private static final Method COLOR_CHANGE_METHOD;
- static {
- try {
- COLOR_CHANGE_METHOD = ColorChangeListener.class.getDeclaredMethod(
- "colorChanged", new Class[] { ColorChangeEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in ColorPicker");
- }
- }
-
private ColorPickerGridServerRpc rpc = new ColorPickerGridServerRpc() {
@Override
public void select(int x, int y) {
ColorPickerGrid.this.x = x;
ColorPickerGrid.this.y = y;
-
- fireColorChanged(colorGrid[y][x]);
+ fireEvent(new ValueChange<>(ColorPickerGrid.this,
+ colorGrid[y][x], true));
}
@Override
public void refresh() {
- for (int row = 0; row < rows; row++) {
- for (int col = 0; col < columns; col++) {
+ for (int row = 0; row < getRows(); row++) {
+ for (int col = 0; col < getColumns(); col++) {
changedColors.put(new Point(row, col), colorGrid[row][col]);
}
}
@@ -70,32 +55,21 @@ public class ColorPickerGrid extends AbstractComponent
}
};
- /** The x-coordinate. */
+ /** The selected x coordinate. */
private int x = 0;
- /** The y-coordinate. */
+ /** The selected y coordinate. */
private int y = 0;
- /** The rows. */
- private int rows;
-
- /** The columns. */
- private int columns;
-
- /** The color grid. */
- private Color[][] colorGrid = new Color[1][1];
+ private Color[][] colorGrid;
- /** The changed colors. */
- private final Map<Point, Color> changedColors = new HashMap<Point, Color>();
+ private final Map<Point, Color> changedColors = new HashMap<>();
/**
* Instantiates a new color picker grid.
*/
public ColorPickerGrid() {
- registerRpc(rpc);
- setPrimaryStyleName(STYLENAME);
- setColorGrid(new Color[1][1]);
- setColor(Color.WHITE);
+ this(1, 1);
}
/**
@@ -107,10 +81,8 @@ public class ColorPickerGrid extends AbstractComponent
* the columns
*/
public ColorPickerGrid(int rows, int columns) {
- registerRpc(rpc);
- setPrimaryStyleName(STYLENAME);
- setColorGrid(new Color[rows][columns]);
- setColor(Color.WHITE);
+ this(new Color[rows][columns]);
+ setValue(Color.WHITE);
}
/**
@@ -126,20 +98,18 @@ public class ColorPickerGrid extends AbstractComponent
}
private void setColumnCount(int columns) {
- this.columns = columns;
getState().columnCount = columns;
}
private void setRowCount(int rows) {
- this.rows = rows;
getState().rowCount = rows;
}
private void sendChangedColors() {
if (!changedColors.isEmpty()) {
String[] colors = new String[changedColors.size()];
- String[] XCoords = new String[changedColors.size()];
- String[] YCoords = new String[changedColors.size()];
+ String[] xCoords = new String[changedColors.size()];
+ String[] yCoords = new String[changedColors.size()];
int counter = 0;
for (Point p : changedColors.keySet()) {
Color c = changedColors.get(p);
@@ -150,13 +120,13 @@ public class ColorPickerGrid extends AbstractComponent
String color = c.getCSS();
colors[counter] = color;
- XCoords[counter] = String.valueOf((int) p.getX());
- YCoords[counter] = String.valueOf((int) p.getY());
+ xCoords[counter] = String.valueOf((int) p.getX());
+ yCoords[counter] = String.valueOf((int) p.getY());
counter++;
}
getState().changedColor = colors;
- getState().changedX = XCoords;
- getState().changedY = YCoords;
+ getState().changedX = xCoords;
+ getState().changedY = yCoords;
changedColors.clear();
}
@@ -173,39 +143,12 @@ public class ColorPickerGrid extends AbstractComponent
setColumnCount(colors[0].length);
colorGrid = colors;
- for (int row = 0; row < rows; row++) {
- for (int col = 0; col < columns; col++) {
+ for (int row = 0; row < getRows(); row++) {
+ for (int col = 0; col < getColumns(); col++) {
changedColors.put(new Point(row, col), colorGrid[row][col]);
}
}
sendChangedColors();
-
- markAsDirty();
- }
-
- @Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
- return () -> removeListener(ColorChangeEvent.class, listener);
- }
-
- @Override
- public Color getColor() {
- return colorGrid[x][y];
- }
-
- @Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- removeListener(ColorChangeEvent.class, listener);
- }
-
- @Override
- public void setColor(Color color) {
- colorGrid[x][y] = color;
- changedColors.put(new Point(x, y), color);
- sendChangedColors();
- markAsDirty();
}
/**
@@ -217,7 +160,7 @@ public class ColorPickerGrid extends AbstractComponent
* the y
*/
public void setPosition(int x, int y) {
- if (x >= 0 && x < columns && y >= 0 && y < rows) {
+ if (x >= 0 && x < getColumns() && y >= 0 && y < getRows()) {
this.x = x;
this.y = y;
}
@@ -232,18 +175,33 @@ public class ColorPickerGrid extends AbstractComponent
return new int[] { x, y };
}
- /**
- * Notifies the listeners that a color change has occurred
- *
- * @param color
- * The color which it changed to
- */
- public void fireColorChanged(Color color) {
- fireEvent(new ColorChangeEvent(this, color));
+ @Override
+ public Color getValue() {
+ return colorGrid[x][y];
+ }
+
+ @Override
+ protected void doSetValue(Color color) {
+ colorGrid[x][y] = color;
+ changedColors.put(new Point(x, y), color);
+ sendChangedColors();
}
@Override
protected ColorPickerGridState getState() {
return (ColorPickerGridState) super.getState();
}
+
+ @Override
+ protected ColorPickerGridState getState(boolean markAsDirty) {
+ return (ColorPickerGridState) super.getState(markAsDirty);
+ }
+
+ private int getColumns() {
+ return getState(false).columnCount;
+ }
+
+ private int getRows() {
+ return getState(false).rowCount;
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
index de0b1f4c52..c875df7482 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
@@ -15,7 +15,6 @@
*/
package com.vaadin.ui.components.colorpicker;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -23,57 +22,43 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
-import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
-import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
/**
* A component that represents color selection history within a color picker.
*
* @since 7.0.0
*/
-public class ColorPickerHistory extends CustomComponent
- implements ColorSelector, ColorChangeListener {
+public class ColorPickerHistory extends CustomField<Color> {
private static final String STYLENAME = "v-colorpicker-history";
- private static final Method COLOR_CHANGE_METHOD;
- static {
- try {
- COLOR_CHANGE_METHOD = ColorChangeListener.class.getDeclaredMethod(
- "colorChanged", new Class[] { ColorChangeEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in ColorPicker");
- }
- }
+ private static final int ROWS = 4;
- /** The rows. */
- private static final int rows = 4;
-
- /** The columns. */
- private static final int columns = 15;
+ private static final int COLUMNS = 15;
/** Temporary color history for when the component is detached. */
- private ArrayBlockingQueue<Color> tempHistory = new ArrayBlockingQueue<Color>(
- rows * columns);
-
- /** The grid. */
- private final ColorPickerGrid grid;
+ private ArrayBlockingQueue<Color> tempHistory = new ArrayBlockingQueue<>(
+ ROWS * COLUMNS);
- /**
- * Instantiates a new color picker history.
- */
- public ColorPickerHistory() {
+ @Override
+ protected Component initContent() {
setPrimaryStyleName(STYLENAME);
- grid = new ColorPickerGrid(rows, columns);
+ ColorPickerGrid grid = new ColorPickerGrid(ROWS, COLUMNS);
grid.setWidth("100%");
grid.setPosition(0, 0);
- grid.addColorChangeListener(this);
+ grid.addValueChangeListener(event -> fireEvent(new ValueChange<>(this,
+ event.isUserOriginated())));
- setCompositionRoot(grid);
+ return grid;
+ }
+
+ @Override
+ protected ColorPickerGrid getContent() {
+ return (ColorPickerGrid) super.getContent();
}
@Override
@@ -83,13 +68,13 @@ public class ColorPickerHistory extends CustomComponent
}
private void createColorHistoryIfNecessary() {
- List<Color> tempColors = new ArrayList<Color>(tempHistory);
+ List<Color> tempColors = new ArrayList<>(tempHistory);
if (getSession().getAttribute("colorPickerHistory") == null) {
getSession().setAttribute("colorPickerHistory",
- new ArrayBlockingQueue<Color>(rows * columns));
+ new ArrayBlockingQueue<Color>(ROWS * COLUMNS));
}
for (Color color : tempColors) {
- setColor(color);
+ setValue(color);
}
tempHistory.clear();
}
@@ -109,11 +94,16 @@ public class ColorPickerHistory extends CustomComponent
@Override
public void setHeight(String height) {
super.setHeight(height);
- grid.setHeight(height);
+ getContent().setHeight(height);
+ }
+
+ @Override
+ public Color getValue() {
+ return getColorHistory().peek();
}
@Override
- public void setColor(Color color) {
+ protected void doSetValue(Color color) {
ArrayBlockingQueue<Color> colorHistory = getColorHistory();
@@ -135,7 +125,7 @@ public class ColorPickerHistory extends CustomComponent
}
}
- List<Color> colorList = new ArrayList<Color>(colorHistory);
+ List<Color> colorList = new ArrayList<>(colorHistory);
// Invert order of colors
Collections.reverse(colorList);
@@ -144,11 +134,11 @@ public class ColorPickerHistory extends CustomComponent
Collections.swap(colorList, colorList.indexOf(color), 0);
// Create 2d color map
- Color[][] colors = new Color[rows][columns];
+ Color[][] colors = new Color[ROWS][COLUMNS];
iter = colorList.iterator();
- for (int row = 0; row < rows; row++) {
- for (int col = 0; col < columns; col++) {
+ for (int row = 0; row < ROWS; row++) {
+ for (int col = 0; col < COLUMNS; col++) {
if (iter.hasNext()) {
colors[row][col] = iter.next();
} else {
@@ -157,13 +147,8 @@ public class ColorPickerHistory extends CustomComponent
}
}
- grid.setColorGrid(colors);
- grid.markAsDirty();
- }
-
- @Override
- public Color getColor() {
- return getColorHistory().peek();
+ getContent().setColorGrid(colors);
+ getContent().markAsDirty();
}
/**
@@ -188,21 +173,4 @@ public class ColorPickerHistory extends CustomComponent
public boolean hasColor(Color c) {
return getColorHistory().contains(c);
}
-
- @Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
- return () -> removeListener(ColorChangeEvent.class, listener);
- }
-
- @Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- removeListener(ColorChangeEvent.class, listener);
- }
-
- @Override
- public void colorChanged(ColorChangeEvent event) {
- fireEvent(new ColorChangeEvent(this, event.getColor()));
- }
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index 2fd58af3c2..4460b21d33 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -15,15 +15,16 @@
*/
package com.vaadin.ui.components.colorpicker;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.vaadin.data.HasValue;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.colorpicker.Color;
@@ -31,7 +32,6 @@ import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
@@ -46,23 +46,10 @@ import com.vaadin.ui.Window;
*
* @since 7.0.0
*/
-public class ColorPickerPopup extends Window
- implements ClickListener, ColorChangeListener, ColorSelector {
+public class ColorPickerPopup extends Window implements HasValue<Color> {
private static final String STYLENAME = "v-colorpicker-popup";
- private static final Method COLOR_CHANGE_METHOD;
- static {
- try {
- COLOR_CHANGE_METHOD = ColorChangeListener.class.getDeclaredMethod(
- "colorChanged", new Class[] { ColorChangeEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in ColorPicker");
- }
- }
-
/** The tabs. */
private final TabSheet tabs = new TabSheet();
@@ -130,7 +117,7 @@ public class ColorPickerPopup extends Window
private ColorPickerSelect colorSelect;
/** The selectors. */
- private final Set<ColorSelector> selectors = new HashSet<>();
+ private final Set<HasValue<Color>> selectors = new HashSet<>();
/**
* Set true while the slider values are updated after colorChange. When
@@ -155,7 +142,7 @@ public class ColorPickerPopup extends Window
setImmediate(true);
// Create the history
history = new ColorPickerHistory();
- history.addColorChangeListener(this);
+ history.addValueChangeListener(this::colorChanged);
}
/**
@@ -175,21 +162,21 @@ public class ColorPickerPopup extends Window
rgbPreview = new ColorPickerPreview(selectedColor);
rgbPreview.setWidth("240px");
rgbPreview.setHeight("20px");
- rgbPreview.addColorChangeListener(this);
+ rgbPreview.addValueChangeListener(this::colorChanged);
selectors.add(rgbPreview);
// Create the preview on the hsv tab
hsvPreview = new ColorPickerPreview(selectedColor);
hsvPreview.setWidth("240px");
hsvPreview.setHeight("20px");
- hsvPreview.addColorChangeListener(this);
+ hsvPreview.addValueChangeListener(this::colorChanged);
selectors.add(hsvPreview);
// Create the preview on the swatches tab
selPreview = new ColorPickerPreview(selectedColor);
selPreview.setWidth("100%");
selPreview.setHeight("20px");
- selPreview.addColorChangeListener(this);
+ selPreview.addValueChangeListener(this::colorChanged);
selectors.add(selPreview);
// Create the tabs
@@ -231,7 +218,7 @@ public class ColorPickerPopup extends Window
layout.addComponent(historyContainer);
// Add the resize button for the history
- resize.addClickListener(this);
+ resize.addClickListener(this::resizeButtonClick);
resize.setData(new Boolean(false));
resize.setWidth("100%");
resize.setHeight("10px");
@@ -240,10 +227,10 @@ public class ColorPickerPopup extends Window
// Add the buttons
ok.setWidth("70px");
- ok.addClickListener(this);
+ ok.addClickListener(this::okButtonClick);
cancel.setWidth("70px");
- cancel.addClickListener(this);
+ cancel.addClickListener(this::cancelButtonClick);
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(ok);
@@ -268,8 +255,8 @@ public class ColorPickerPopup extends Window
// Add the RGB color gradient
rgbGradient = new ColorPickerGradient("rgb-gradient", rgbConverter);
- rgbGradient.setColor(color);
- rgbGradient.addColorChangeListener(this);
+ rgbGradient.setValue(color);
+ rgbGradient.addValueChangeListener(this::colorChanged);
rgbLayout.addComponent(rgbGradient);
selectors.add(rgbGradient);
@@ -287,7 +274,7 @@ public class ColorPickerPopup extends Window
if (!updatingColors) {
Color newColor = new Color((int) red, selectedColor.getGreen(),
selectedColor.getBlue());
- setColor(newColor);
+ setValue(newColor);
}
});
@@ -298,7 +285,7 @@ public class ColorPickerPopup extends Window
if (!updatingColors) {
Color newColor = new Color(selectedColor.getRed(), (int) green,
selectedColor.getBlue());
- setColor(newColor);
+ setValue(newColor);
}
});
sliders.addComponent(greenSlider);
@@ -308,7 +295,7 @@ public class ColorPickerPopup extends Window
if (!updatingColors) {
Color newColor = new Color(selectedColor.getRed(),
selectedColor.getGreen(), (int) blue);
- setColor(newColor);
+ setValue(newColor);
}
});
sliders.addComponent(blueSlider);
@@ -340,8 +327,8 @@ public class ColorPickerPopup extends Window
// Add the hsv gradient
hsvGradient = new ColorPickerGradient("hsv-gradient", hsvConverter);
- hsvGradient.setColor(color);
- hsvGradient.addColorChangeListener(this);
+ hsvGradient.setValue(color);
+ hsvGradient.addValueChangeListener(this::colorChanged);
hsvLayout.addComponent(hsvGradient);
selectors.add(hsvGradient);
@@ -372,7 +359,7 @@ public class ColorPickerPopup extends Window
// Set the color
Color newColor = new Color(
Color.HSVtoRGB(hue, saturation, value));
- setColor(newColor);
+ setValue(newColor);
/*
* Set the background color of the hue gradient. This has to be
@@ -398,7 +385,7 @@ public class ColorPickerPopup extends Window
.parseFloat(valueSlider.getValue().toString())) / 100f;
Color newColor = new Color(
Color.HSVtoRGB(hue, saturation, value));
- setColor(newColor);
+ setValue(newColor);
}
});
sliders.addComponent(saturationSlider);
@@ -418,7 +405,7 @@ public class ColorPickerPopup extends Window
Color newColor = new Color(
Color.HSVtoRGB(hue, saturation, value));
- setColor(newColor);
+ setValue(newColor);
}
});
@@ -440,42 +427,33 @@ public class ColorPickerPopup extends Window
selLayout.addStyleName("seltab");
colorSelect = new ColorPickerSelect();
- colorSelect.addColorChangeListener(this);
+ colorSelect.addValueChangeListener(this::colorChanged);
selLayout.addComponent(colorSelect);
return selLayout;
}
- @Override
- public void buttonClick(ClickEvent event) {
- if (event.getButton() == resize) {
-
- boolean minimize = (Boolean) resize.getData();
- if (minimize) {
- historyContainer.setHeight("27px");
- history.setHeight("22px");
- } else {
- historyContainer.setHeight("90px");
- history.setHeight("85px");
- }
+ private void resizeButtonClick(ClickEvent event) {
- resize.setData(new Boolean(!minimize));
+ boolean minimize = (Boolean) resize.getData();
+ if (minimize) {
+ historyContainer.setHeight("27px");
+ history.setHeight("22px");
+ } else {
+ historyContainer.setHeight("90px");
+ history.setHeight("85px");
+ }
- } else if (event.getButton() == ok) {
- history.setColor(getColor());
- fireColorChanged();
- close();
+ resize.setData(new Boolean(!minimize));
+ }
- } else if (event.getButton() == cancel) {
- close();
- }
+ private void okButtonClick(ClickEvent event) {
+ fireEvent(new ValueChange<>(this, true));
+ close();
}
- /**
- * Notifies the listeners that the color changed.
- */
- public void fireColorChanged() {
- fireEvent(new ColorChangeEvent(this, getColor()));
+ private void cancelButtonClick(ClickEvent event) {
+ close();
}
/**
@@ -488,27 +466,36 @@ public class ColorPickerPopup extends Window
}
@Override
- public void setColor(Color color) {
+ public void setValue(Color color) {
if (color == null) {
return;
}
selectedColor = color;
- hsvGradient.setColor(selectedColor);
- hsvPreview.setColor(selectedColor);
+ hsvGradient.setValue(selectedColor);
+ hsvPreview.setValue(selectedColor);
- rgbGradient.setColor(selectedColor);
- rgbPreview.setColor(selectedColor);
+ rgbGradient.setValue(selectedColor);
+ rgbPreview.setValue(selectedColor);
- selPreview.setColor(selectedColor);
+ selPreview.setValue(selectedColor);
}
@Override
- public Color getColor() {
+ public Color getValue() {
return selectedColor;
}
+ @Override
+ public Registration addValueChangeListener(
+ ValueChangeListener<? super Color> listener) {
+ Objects.requireNonNull(listener, "listener cannot be null");
+ addListener(ValueChange.class, listener,
+ ValueChangeListener.VALUE_CHANGE_METHOD);
+ return () -> removeListener(ValueChange.class, listener);
+ }
+
/**
* Gets the color history.
*
@@ -518,9 +505,8 @@ public class ColorPickerPopup extends Window
return Collections.unmodifiableList(history.getHistory());
}
- @Override
- public void colorChanged(ColorChangeEvent event) {
- setColor(event.getColor());
+ private void colorChanged(ValueChange<Color> event) {
+ setValue(event.getValue());
updatingColors = true;
@@ -530,10 +516,10 @@ public class ColorPickerPopup extends Window
updatingColors = false;
- for (ColorSelector s : selectors) {
+ for (HasValue<Color> s : selectors) {
if (event.getSource() != s && s != this
- && s.getColor() != selectedColor) {
- s.setColor(selectedColor);
+ && s.getValue() != selectedColor) {
+ s.setValue(selectedColor);
}
}
}
@@ -562,18 +548,6 @@ public class ColorPickerPopup extends Window
}
}
- @Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
- return () -> removeListener(ColorChangeEvent.class, listener);
- }
-
- @Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- removeListener(ColorChangeEvent.class, listener);
- }
-
/**
* Checks the visibility of the given tab
*
@@ -649,6 +623,7 @@ public class ColorPickerPopup extends Window
* Sets the visibility of the History.
*
* @param visible
+ * {@code true} to show the history, {@code false} to hide it
*/
public void setHistoryVisible(boolean visible) {
historyContainer.setVisible(visible);
@@ -659,6 +634,7 @@ public class ColorPickerPopup extends Window
* Sets the preview visibility.
*
* @param visible
+ * {@code true} to show the preview, {@code false} to hide it
*/
public void setPreviewVisible(boolean visible) {
hsvPreview.setVisible(visible);
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index c747002bde..3d743f7365 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -15,9 +15,9 @@
*/
package com.vaadin.ui.components.colorpicker;
-import java.lang.reflect.Method;
+import java.util.Objects;
-import com.vaadin.data.HasValue.ValueChange;
+import com.vaadin.data.HasValue;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.ui.Component;
@@ -29,23 +29,11 @@ import com.vaadin.ui.TextField;
*
* @since 7.0.0
*/
-public class ColorPickerPreview extends CssLayout implements ColorSelector {
+public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
private static final String STYLE_DARK_COLOR = "v-textfield-dark";
private static final String STYLE_LIGHT_COLOR = "v-textfield-light";
- private static final Method COLOR_CHANGE_METHOD;
- static {
- try {
- COLOR_CHANGE_METHOD = ColorChangeListener.class.getDeclaredMethod(
- "colorChanged", new Class[] { ColorChangeEvent.class });
- } catch (final java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException(
- "Internal error finding methods in ColorPicker");
- }
- }
-
/** The color. */
private Color color;
@@ -74,11 +62,11 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector {
*/
public ColorPickerPreview(Color color) {
this();
- setColor(color);
+ setValue(color);
}
@Override
- public void setColor(Color color) {
+ public void setValue(Color color) {
this.color = color;
// Unregister listener
@@ -107,23 +95,20 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector {
}
@Override
- public Color getColor() {
+ public Color getValue() {
return color;
}
@Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
- return () -> removeListener(ColorChangeEvent.class, listener);
+ public Registration addValueChangeListener(
+ ValueChangeListener<? super Color> listener) {
+ Objects.requireNonNull(listener, "listener cannot be null");
+ addListener(ValueChange.class, listener,
+ ValueChangeListener.VALUE_CHANGE_METHOD);
+ return () -> removeListener(ValueChange.class, listener);
}
- @Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- removeListener(ColorChangeEvent.class, listener);
- }
-
- public void valueChange(ValueChange<String> event) {
+ private void valueChange(ValueChange<String> event) {
String value = event.getValue();
try {
if (value != null) {
@@ -177,8 +162,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector {
}
oldValue = value;
- fireEvent(new ColorChangeEvent((Component) field.getData(),
- color));
+ fireEvent(new ValueChange<>((Component) field.getData(),
+ color, event.isUserOriginated()));
}
} catch (NumberFormatException nfe) {
@@ -187,9 +172,6 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector {
}
}
- /**
- * Called when the component is refreshing
- */
@Override
protected String getCss(Component c) {
return "background: " + color.getCSS();
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
index fd37d3345a..9e84640218 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
@@ -17,11 +17,10 @@ package com.vaadin.ui.components.colorpicker;
import java.util.EnumSet;
-import com.vaadin.data.HasValue.ValueChange;
-import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
import com.vaadin.ui.VerticalLayout;
/**
@@ -29,32 +28,19 @@ import com.vaadin.ui.VerticalLayout;
*
* @since 7.0.0
*/
-public class ColorPickerSelect extends CustomComponent
- implements ColorSelector {
+public class ColorPickerSelect extends CustomField<Color> {
- /** The range. */
- private final ComboBox<ColorRangePropertyId> range;
+ private ComboBox<ColorRange> range;
- /** The grid. */
- private final ColorPickerGrid grid;
+ private ColorPickerGrid grid;
- /**
- * The Enum ColorRangePropertyId.
- */
- private enum ColorRangePropertyId {
+ private enum ColorRange {
ALL("All colors"), RED("Red colors"), GREEN("Green colors"), BLUE(
"Blue colors");
- /** The caption. */
private String caption;
- /**
- * Instantiates a new color range property id.
- *
- * @param caption
- * the caption
- */
- ColorRangePropertyId(String caption) {
+ ColorRange(String caption) {
this.caption = caption;
}
@@ -64,35 +50,29 @@ public class ColorPickerSelect extends CustomComponent
}
}
- /**
- * Instantiates a new color picker select.
- *
- * @param rows
- * the rows
- * @param columns
- * the columns
- */
- public ColorPickerSelect() {
-
+ @Override
+ protected Component initContent() {
VerticalLayout layout = new VerticalLayout();
- setCompositionRoot(layout);
setStyleName("colorselect");
setWidth("100%");
- range = new ComboBox<>(null, EnumSet.allOf(ColorRangePropertyId.class));
+ range = new ComboBox<>(null, EnumSet.allOf(ColorRange.class));
range.setEmptySelectionAllowed(false);
range.setWidth("100%");
range.addValueChangeListener(this::valueChange);
- range.select(ColorRangePropertyId.ALL);
+ range.select(ColorRange.ALL);
layout.addComponent(range);
grid = new ColorPickerGrid(createAllColors(14, 10));
grid.setWidth("100%");
+ grid.addValueChangeListener(this::fireEvent);
layout.addComponent(grid);
+
+ return layout;
}
/**
@@ -110,9 +90,9 @@ public class ColorPickerSelect extends CustomComponent
for (int row = 0; row < rows; row++) {
for (int col = 0; col < columns; col++) {
-
- // Create the color grid by varying the saturation and value
if (row < (rows - 1)) {
+ // Create the color grid by varying the saturation and value
+
// Calculate new hue value
float hue = ((float) col / (float) columns);
float saturation = 1f;
@@ -128,10 +108,8 @@ public class ColorPickerSelect extends CustomComponent
colors[row][col] = new Color(
Color.HSVtoRGB(hue, saturation, value));
- }
-
- // The last row should have the black&white gradient
- else {
+ } else {
+ // The last row should have the black&white gradient
float hue = 0f;
float saturation = 0f;
float value = 1f - ((float) col / (float) columns);
@@ -190,40 +168,29 @@ public class ColorPickerSelect extends CustomComponent
return colors;
}
- @Override
- public Color getColor() {
- return grid.getColor();
- }
-
- @Override
- public void setColor(Color color) {
- grid.setColor(color);
- }
-
- @Override
- public Registration addColorChangeListener(ColorChangeListener listener) {
- return grid.addColorChangeListener(listener);
- }
-
- @Override
- @Deprecated
- public void removeColorChangeListener(ColorChangeListener listener) {
- grid.removeColorChangeListener(listener);
- }
-
- public void valueChange(ValueChange<ColorRangePropertyId> event) {
+ private void valueChange(ValueChange<ColorRange> event) {
if (grid == null) {
return;
}
- if (event.getValue() == ColorRangePropertyId.ALL) {
+ if (event.getValue() == ColorRange.ALL) {
grid.setColorGrid(createAllColors(14, 10));
- } else if (event.getValue() == ColorRangePropertyId.RED) {
+ } else if (event.getValue() == ColorRange.RED) {
grid.setColorGrid(createColors(new Color(0xFF, 0, 0), 14, 10));
- } else if (event.getValue() == ColorRangePropertyId.GREEN) {
+ } else if (event.getValue() == ColorRange.GREEN) {
grid.setColorGrid(createColors(new Color(0, 0xFF, 0), 14, 10));
- } else if (event.getValue() == ColorRangePropertyId.BLUE) {
+ } else if (event.getValue() == ColorRange.BLUE) {
grid.setColorGrid(createColors(new Color(0, 0, 0xFF), 14, 10));
}
}
+
+ @Override
+ public Color getValue() {
+ return grid.getValue();
+ }
+
+ @Override
+ protected void doSetValue(Color value) {
+ grid.setValue(value);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorSelector.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorSelector.java
deleted file mode 100644
index d9264745a8..0000000000
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorSelector.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2000-2016 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
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui.components.colorpicker;
-
-import java.io.Serializable;
-
-import com.vaadin.shared.ui.colorpicker.Color;
-
-/**
- * An interface for a color selector.
- *
- * @since 7.0.0
- */
-public interface ColorSelector extends Serializable, HasColorChangeListener {
-
- /**
- * Sets the color.
- *
- * @param color
- * the new color
- */
- public void setColor(Color color);
-
- /**
- * Gets the color.
- *
- * @return the color
- */
- public Color getColor();
-}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
deleted file mode 100644
index 505365ec63..0000000000
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2000-2016 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
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui.components.colorpicker;
-
-import java.io.Serializable;
-
-import com.vaadin.shared.Registration;
-
-public interface HasColorChangeListener extends Serializable {
-
- /**
- * Adds a {@link ColorChangeListener} to the component.
- *
- * @see Registration
- *
- * @param listener
- * the listener to add, not null
- * @return a registration object for removing the listener
- */
- Registration addColorChangeListener(ColorChangeListener listener);
-
- /**
- * Removes a {@link ColorChangeListener} from the component.
- *
- * @param listener
- * the listener to remove
- *
- * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
- * registration object returned from
- * {@link #addColorChangeListener(ColorChangeListener)}.
- */
- @Deprecated
- void removeColorChangeListener(ColorChangeListener listener);
-
-}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGradientState.java b/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGradientState.java
index cf14ddb29f..5af85709bc 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGradientState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGradientState.java
@@ -15,14 +15,14 @@
*/
package com.vaadin.shared.ui.colorpicker;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.AbstractFieldState;
/**
* Default shared state implementation for ColorPickerGradient.
*
* @since 7.0.0
*/
-public class ColorPickerGradientState extends AbstractComponentState {
+public class ColorPickerGradientState extends AbstractFieldState {
public int cursorX;
diff --git a/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGridState.java b/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGridState.java
index ae04317cb6..75374777b2 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGridState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/colorpicker/ColorPickerGridState.java
@@ -15,14 +15,14 @@
*/
package com.vaadin.shared.ui.colorpicker;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.AbstractFieldState;
/**
* Default shared state implementation for ColorPickerGrid.
*
* @since 7.0.0
*/
-public class ColorPickerGridState extends AbstractComponentState {
+public class ColorPickerGridState extends AbstractFieldState {
public int rowCount;
diff --git a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java
index e80633bcdf..cc78f95585 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java
@@ -50,7 +50,7 @@ public class ColorPickerTestUI extends AbstractTestUI {
@Override
public String getTestDescription() {
- return "Vaadin 7 compatible ColorPicker";
+ return "Vaadin 8 compatible ColorPicker";
}
@Override