package com.vaadin.client.ui.colorpicker;
+import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseMoveEvent;
import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
-import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
+import com.vaadin.client.ui.SubPartAware;
/**
* Client side implementation for ColorPickerGradient.
*
*/
public class VColorPickerGradient extends FocusPanel implements
- MouseDownHandler, MouseUpHandler, MouseMoveHandler {
+ MouseDownHandler, MouseUpHandler, MouseMoveHandler, SubPartAware {
/** Set the CSS class name to allow styling. */
public static final String CLASSNAME = "v-colorpicker-gradient";
public static final String CLASSNAME_HIGHERBOX = CLASSNAME + "-higherbox";
public static final String CLASSNAME_CONTAINER = CLASSNAME + "-container";
public static final String CLASSNAME_CLICKLAYER = CLASSNAME + "-clicklayer";
+ private static final String CLICKLAYER_ID = "clicklayer";
private final HTML background;
private final HTML foreground;
private int cursorX;
private int cursorY;
+ private int width = 220;
+ private int height = 220;
+
/**
* Instantiates the client side component for a color picker gradient.
*/
setStyleName(CLASSNAME);
- int width = 220;
- int height = 220;
-
background = new HTML();
background.setStyleName(CLASSNAME_BACKGROUND);
background.setPixelSize(width, height);
* @param bgColor
*/
protected void setBGColor(String bgColor) {
- background.getElement().getStyle().setProperty("background", bgColor);
+ if (bgColor == null) {
+ background.getElement().getStyle().clearBackgroundColor();
+ } else {
+ background.getElement().getStyle().setBackgroundColor(bgColor);
+ }
}
@Override
cursorX = x;
cursorY = y;
if (x >= 0) {
- DOM.setStyleAttribute(lowercross.getElement(), "width",
- String.valueOf(x) + "px");
+ lowercross.getElement().getStyle().setWidth(x, Unit.PX);
}
if (y >= 0) {
- DOM.setStyleAttribute(lowercross.getElement(), "top",
- String.valueOf(y) + "px");
+ lowercross.getElement().getStyle().setTop(y, Unit.PX);
}
if (y >= 0) {
- DOM.setStyleAttribute(lowercross.getElement(), "height",
- String.valueOf((background.getOffsetHeight() - y)) + "px");
+ lowercross.getElement().getStyle().setHeight(height - y, Unit.PX);
}
if (x >= 0) {
- DOM.setStyleAttribute(highercross.getElement(), "width",
- String.valueOf((background.getOffsetWidth() - x)) + "px");
+ highercross.getElement().getStyle().setWidth(width - x, Unit.PX);
}
if (x >= 0) {
- DOM.setStyleAttribute(highercross.getElement(), "left",
- String.valueOf(x) + "px");
+ highercross.getElement().getStyle().setLeft(x, Unit.PX);
}
if (y >= 0) {
- DOM.setStyleAttribute(highercross.getElement(), "height",
- String.valueOf((y)) + "px");
+ highercross.getElement().getStyle().setHeight(y, Unit.PX);
+ }
+ }
+
+ @Override
+ public Element getSubPartElement(String subPart) {
+ if (subPart.equals(CLICKLAYER_ID)) {
+ return clicklayer.getElement();
}
+
+ return null;
+ }
+
+ @Override
+ public String getSubPartName(Element subElement) {
+ if (clicklayer.getElement().isOrHasChild(subElement)) {
+ return CLICKLAYER_ID;
+ }
+
+ return null;
}
}
<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="http://localhost:8888/run/com.vaadin.tests.components.colorpicker.ColorPickerTest?restartApplication" />
+<link rel="selenium.base" href="" />
<title>ColorPickerTest</title>
</head>
<body>
<td>colorpicker1</td>
<td></td>
</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td>
+ <td></td>
+</tr>
<tr>
<td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td>
<td>190,87</td>
</tr>
<tr>
</tr>
<tr>
<td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td>
<td>51,33</td>
</tr>
<tr>
</tr>
<tr>
<td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td>
<td>148,127</td>
</tr>
<tr>
</tr>
<tr>
<td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td>
+ <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td>
<td>36,93</td>
</tr>
<tr>