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.

ColorPickerConnector.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2000-2016 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.v7.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.communication.RpcProxy;
  21. import com.vaadin.client.ui.VColorPicker;
  22. import com.vaadin.shared.ui.Connect;
  23. import com.vaadin.shared.ui.Connect.LoadStyle;
  24. import com.vaadin.v7.shared.ui.colorpicker.ColorPickerServerRpc;
  25. /**
  26. * A class that defines default implementation for a color picker connector.
  27. * Connects the server side {@link com.vaadin.ui.ColorPicker} with the client
  28. * side counterpart {@link VColorPicker}
  29. *
  30. * @since 7.0.0
  31. */
  32. @Deprecated
  33. @Connect(value = com.vaadin.v7.ui.ColorPicker.class, loadStyle = LoadStyle.LAZY)
  34. public class ColorPickerConnector extends AbstractColorPickerConnector {
  35. private ColorPickerServerRpc rpc = RpcProxy
  36. .create(ColorPickerServerRpc.class, this);
  37. @Override
  38. protected Widget createWidget() {
  39. return GWT.create(VColorPicker.class);
  40. }
  41. @Override
  42. public VColorPicker getWidget() {
  43. return (VColorPicker) super.getWidget();
  44. }
  45. @Override
  46. public void onClick(ClickEvent event) {
  47. rpc.openPopup(getWidget().isOpen());
  48. }
  49. @Override
  50. protected void setCaption(String caption) {
  51. if (getState().captionAsHtml) {
  52. getWidget().setHtml(caption);
  53. } else {
  54. getWidget().setText(caption);
  55. }
  56. }
  57. @Override
  58. protected void refreshColor() {
  59. getWidget().refreshColor();
  60. }
  61. }