Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

AbstractFieldConnector.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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;
  17. import com.vaadin.client.StyleConstants;
  18. import com.vaadin.client.ui.AbstractComponentConnector;
  19. import com.vaadin.client.ui.HasErrorIndicator;
  20. import com.vaadin.client.ui.HasRequiredIndicator;
  21. import com.vaadin.v7.shared.AbstractFieldState;
  22. @Deprecated
  23. public abstract class AbstractFieldConnector extends AbstractComponentConnector
  24. implements HasRequiredIndicator, HasErrorIndicator {
  25. @Override
  26. public AbstractFieldState getState() {
  27. return (AbstractFieldState) super.getState();
  28. }
  29. @Override
  30. public boolean isReadOnly() {
  31. return super.isReadOnly() || getState().propertyReadOnly;
  32. }
  33. public boolean isModified() {
  34. return getState().modified;
  35. }
  36. /**
  37. * Checks whether the required indicator should be shown for the field.
  38. *
  39. * Required indicators are hidden if the field or its data source is
  40. * read-only.
  41. *
  42. * @return true if required indicator should be shown
  43. */
  44. @Override
  45. public boolean isRequiredIndicatorVisible() {
  46. return getState().required && !isReadOnly();
  47. }
  48. @Override
  49. public boolean isErrorIndicatorVisible() {
  50. return super.isErrorIndicatorVisible() && !getState().hideErrors;
  51. }
  52. @Override
  53. protected void updateWidgetStyleNames() {
  54. super.updateWidgetStyleNames();
  55. // add / remove modified style name to Fields
  56. setWidgetStyleName(StyleConstants.MODIFIED, isModified());
  57. // add / remove error style name to Fields
  58. setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
  59. StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
  60. getWidget().setStyleName(StyleConstants.REQUIRED,
  61. isRequiredIndicatorVisible());
  62. }
  63. }