選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AbstractFieldConnector.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import com.vaadin.shared.AbstractFieldState;
  6. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  7. public abstract class AbstractFieldConnector extends AbstractComponentConnector {
  8. @Override
  9. public AbstractFieldState getState() {
  10. return (AbstractFieldState) super.getState();
  11. }
  12. @Override
  13. public boolean isReadOnly() {
  14. return super.isReadOnly() || getState().isPropertyReadOnly();
  15. }
  16. public boolean isModified() {
  17. return getState().isModified();
  18. }
  19. /**
  20. * Checks whether the required indicator should be shown for the field.
  21. *
  22. * Required indicators are hidden if the field or its data source is
  23. * read-only.
  24. *
  25. * @return true if required indicator should be shown
  26. */
  27. public boolean isRequired() {
  28. return getState().isRequired() && !isReadOnly();
  29. }
  30. @Override
  31. protected void updateWidgetStyleNames() {
  32. super.updateWidgetStyleNames();
  33. // add / remove modified style name to Fields
  34. setWidgetStyleName(ApplicationConnection.MODIFIED_CLASSNAME,
  35. isModified());
  36. // add / remove error style name to Fields
  37. setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
  38. ApplicationConnection.REQUIRED_CLASSNAME_EXT, isRequired());
  39. }
  40. }