You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ColorPickerAreaConnector.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.ui.colorpicker;
  17. import com.google.gwt.core.client.GWT;
  18. import com.google.gwt.event.dom.client.ClickEvent;
  19. import com.google.gwt.user.client.ui.Widget;
  20. import com.vaadin.client.VCaption;
  21. import com.vaadin.client.communication.RpcProxy;
  22. import com.vaadin.client.ui.VColorPickerArea;
  23. import com.vaadin.shared.ui.Connect;
  24. import com.vaadin.shared.ui.Connect.LoadStyle;
  25. import com.vaadin.shared.ui.colorpicker.ColorPickerAreaState;
  26. import com.vaadin.shared.ui.colorpicker.ColorPickerServerRpc;
  27. import com.vaadin.ui.ColorPickerArea;
  28. /**
  29. * A class that defines an implementation for a color picker connector. Connects
  30. * the server side {@link com.vaadin.ui.ColorPickerArea} with the client side
  31. * counterpart {@link VColorPickerArea}
  32. *
  33. * @since 7.0.0
  34. */
  35. @Connect(value = ColorPickerArea.class, loadStyle = LoadStyle.LAZY)
  36. public class ColorPickerAreaConnector extends AbstractColorPickerConnector {
  37. private ColorPickerServerRpc rpc = RpcProxy
  38. .create(ColorPickerServerRpc.class, this);
  39. @Override
  40. protected Widget createWidget() {
  41. return GWT.create(VColorPickerArea.class);
  42. }
  43. @Override
  44. public VColorPickerArea getWidget() {
  45. return (VColorPickerArea) super.getWidget();
  46. }
  47. @Override
  48. public void onClick(ClickEvent event) {
  49. rpc.openPopup(getWidget().isOpen());
  50. }
  51. @Override
  52. protected void setCaption(String caption) {
  53. VCaption.setCaptionText(getWidget(), getState());
  54. }
  55. @Override
  56. protected void refreshColor() {
  57. getWidget().refreshColor();
  58. }
  59. @Override
  60. public ColorPickerAreaState getState() {
  61. return (ColorPickerAreaState) super.getState();
  62. }
  63. }